Cropping image with ImageScience

Posted by fl00r on Stack Overflow See other posts from Stack Overflow or by fl00r
Published on 2010-06-06T19:19:37Z Indexed on 2010/06/06 19:22 UTC
Read the original article Hit count: 325

ImageScience is cool and light. I am using it in my sinatra app. But I can't understand how can I crop image with not square form and how can I make thumbnail with two dimensions.

As I found on ImageScience site:

ImageScience.with_image(file) do |img|
  img.cropped_thumbnail(100) do |thumb|
    thumb.save "#{file}_cropped.png"
  end

  img.thumbnail(100) do |thumb|
    thumb.save "#{file}_thumb.png"
  end

  img.resize(100, 150) do |img2|
    img2.save "#{file}_resize.png"
  end
end

I can crop thumb and resize thumb only with ONE dimension but I want to use two, as in RMagick. For example I want to crop 100x200px box from image, or I want to make thumbnail with width or height not bigger then 300 (width) or 500 (height) pixels.

© Stack Overflow or respective owner

Related posts about ruby

Related posts about image-processing