Skip to content

Instantly share code, notes, and snippets.

@jeffdeville
Created December 12, 2011 16:32
Show Gist options
  • Select an option

  • Save jeffdeville/1468109 to your computer and use it in GitHub Desktop.

Select an option

Save jeffdeville/1468109 to your computer and use it in GitHub Desktop.
works in irb, not in rails
require 'RMagick'
require 'open-uri'
require 'ap'
image_urls = %w[http://images3.cpcache.com/product_zoom/215803453v6_460x460_Front_Color-Cardinal_padToSquare-true.jpg http://images2.cpcache.com/product_zoom/292564282v8_460x460_Front_Color-MilitaryGreen_padToSquare-true.jpg http://images0.cpcache.com/product_zoom/57297330v27_460x460_Front_Color-Black_padToSquare-true.jpg]
images = (0..2).collect do |index|
begin
blob = open(image_urls[index]).read
image = Magick::Image.from_blob(blob)[0]
image.resize_to_fit 200, 200
rescue
ap $!
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment