- Notifications
You must be signed in to change notification settings - Fork60
Ruby extension for the libvips image processing library.
License
libvips/ruby-vips
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
This gem is a Ruby binding for thelibvips image processinglibrary. It has been tested onLinux, macOS and Windows, and with ruby 2, ruby 3 and jruby. It usesruby-ffi to call functions in the libvipslibrary.
libvips is ademand-driven, horizontallythreadedimage processing library. Compared to similarlibraries,libvips runs quickly and uses littlememory.libvips is licensed under theLGPL2.1+.
Install the libvips binary with your package manager (eg.apt install libvips42
or perhapsbrew install vips
, see thelibvips installinstructions) then installthis gem with:
gem install ruby-vips
Or includegem "ruby-vips"
in your gemfile.
The gemspec will pull in the msys libvips for you, so all you need is:
gem install ruby-vips
Or includegem "ruby-vips"
in your gemfile.
Tested with the ruby and msys from choco, but others may work.
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
There arefull API docs for ruby-vips onrubydoc. This sometimes has issuesupdating, so we have acopy on the gh-pages for this site aswell, whichshould always work.
See theVips
section in the docs for atutorial introduction withexamples.
Thelibvips reference manualhas a complete explanation of every method.
Theexample/
directory has some simple example programs.
The benchmark atvips-benchmarksloads a large image, crops, shrinks, sharpens and saves again, and repeats10 times.
real time in seconds, fastest of five runsbenchmark tiff jpegruby-vips.rb0.850.78image-magick2.032.44rmagick.rb3.873.89peak memory use in kbbenchmarkpeak RESruby-vips.rb43864rmagick.rb788768
About
Ruby extension for the libvips image processing library.
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.