Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Lightweight image resizing for Ruby, either with vips, imlib2 or ImageMagick.
require 'dimension'
thumb = Dimension.open('tux.png')
thumb.generate('100x100') # => { :width => 100, :height => 100 }
thumb.save('resized.png')
Or generate and write file automatically.
thumb = Dimension.open('tux.png')
thumb.generate!('100x300!') # will write file as 'tux-100x300.png'
Yes sir, we have it.
thumb = Dimension.open(params[:file])
thumb.generate('200x300#')
thumb.image_data
You can also pass a block, which will ensure the original image is closed after processing.
get '/resize/:file' do
thumb = Dimension.open(params[:file])
thumb.generate('200x300@') do
thumb.to_response
end
end
For vips backend:
# install library
apt install libvips42
# then, the ruby bindings
gem install ruby-vips
# and in case you don't get a libvips.so symlink
sudo ln -s /usr/lib/x86_64-linux-gnu/libvips.so.42 /usr/lib/x86_64-linux-gnu/libvips.so
For imlib2 backend:
# install deps
sudo apt install libimlib2-dev
# clone repo
git clone https://github.com/pepabo/imlib2-ruby
cd imlib2-ruby
# build/install
ruby extconf.rb
make
make install
# and clean up
cd ..
rm -Rf imlib2-ruby
For ImageMagick, there's no gem required. Just make sure the binaries (identify, convert) are in place:
sudo apt install imagemagick
Written by Tomás Pollak.
(c) Fork, Ltd. MIT Licensed.
FAQs
Unknown package
We found that dimension demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.