Project

ruby-epeg

0.0
No release in over 3 years
Low commit activity in last 3 years
Ruby extension for the epeg library which provides facilities for scaling JPEG images very quickly.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.7
~> 10.0
~> 3.0
 Project Readme

ruby-epeg Travis CI - build status

Ruby extension for the epeg library which provides facilities for scaling JPEG images very quickly.

Installation

Add this line to your application's Gemfile:

gem 'ruby-epeg', :require => 'epeg'

And then execute:

$ bundle

Or install it yourself as:

$ gem install ruby-epeg

Example

require "epeg"

# Get and set the global default jpeg quality
Epeg::Image.default_quality # => 85
Epeg::Image.default_quality = 90

# Create an image object from the file some-image.jpg
image = Epeg::Image.open("./some-image.jpg")

# You can get the width and height without loading any pixels
"some-image.jpeg is #{image.width}x#{image.height}px"
# => some-image.jpeg is 1000x500

# Resize the image to 50x50, set the quality to 50 and save it
image.resize(50,50).quality(50).write("./some-other-image.jpg")

# The image is now closed and you can't do any further operations
image.closed? # => true

# Load the same image from a buffer
File.open("./some-image.jpg") do |file|
  image = Epeg::Image.from_blob(file.read)
end

# Resize to fill 50x50px (i. e. width and height are at
# least 50px with preserving the aspect ratio) and return the blob
image.resize_to_fill(50,50).to_blob

# Let's crop the resized image
image = Epeg::Image.open("./some-other-image.jpg")
image.crop(50, 50).write("./final-image.jpg")