You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This gem is a Ruby binding for the libvips image processing
library. It has been tested on
Linux, macOS and Windows, and with ruby 2, ruby 3 and jruby. It uses
ruby-ffi to call functions in the libvips
library.
Install the libvips binary with your package manager (eg. apt install libvips42 or perhaps brew install vips, see the libvips install
instructions) then install
this gem with:
gem install ruby-vips
Or include gem "ruby-vips" in your gemfile.
Install on Windows
The gemspec will pull in the msys libvips for you, so all you need is:
gem install ruby-vips
Or include gem "ruby-vips" in your gemfile.
Tested with the ruby and msys from choco, but others may work.
Example
require"vips"im=Vips::Image.new_from_filefilename# put im at position (100, 100) in a 3000 x 3000 pixel image, # make the other pixels in the image by mirroring im up / down / # left / right, see# https://libvips.github.io/libvips/API/current/libvips-conversion.html#vips-embedim=im.embed100,100,3000,3000,extend: :mirror# multiply the green (middle) band by 2, leave the other two aloneim *= [1,2,1]# make an image from an array constant, convolve with itmask=Vips::Image.new_from_array[[-1, -1, -1],[-1,16, -1],[-1, -1, -1]],8im=im.convmask,precision: :integer# finally, write the result back to a file on diskim.write_to_fileoutput_filename
The example/
directory has some simple example programs.
Benchmarks
The benchmark at vips-benchmarks
loads a large image, crops, shrinks, sharpens and saves again, and repeats
10 times.
real time in seconds, fastest of five runs
benchmark tiff jpeg
ruby-vips.rb 0.85 0.78
image-magick 2.03 2.44
rmagick.rb 3.87 3.89
peak memory use in kb
benchmark peak RES
ruby-vips.rb 43864
rmagick.rb 788768