Skip to content

Instantly share code, notes, and snippets.

@averyvery
Created November 14, 2011 20:58
Show Gist options
  • Save averyvery/1365140 to your computer and use it in GitHub Desktop.
Save averyvery/1365140 to your computer and use it in GitHub Desktop.
Resizing retina images with rmagick
guard 'process', :name => 'shrink-images', :command => 'ruby resize-mobile-images.rb' do
watch /^images\/mobileretina\/.+.png/
end
require 'rmagick'
Dir.glob('images/mobileretina/*.png').each do |image_path|
GC.start
image = Magick::Image::read(image_path).first
image.scale!(0.5)
new_path = image_path.sub(/retina/, 'normal')
image.write new_path
image.destroy!
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment