Skip to content

Instantly share code, notes, and snippets.

Created July 3, 2012 21:06
  • Star 8 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save averyvery/3043125 to your computer and use it in GitHub Desktop.
Retina images with Guard
guard 'process', :name => 'shrink-images', :command => 'ruby resize-mobile-images.rb mobileretina' do
watch /^images\/mobileretina\/.+/
require 'rmagick'
source = ARGV[0]
Dir.glob('images/' + source + '/*.*').each do |image_path|
image = Magick::Image::read(image_path).first
image.resize!(image.columns / 2, image.rows / 2, Magick::GaussianFilter, 0.2)
new_path = image_path.sub(/retina/, 'normal')
image.write new_path
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment