DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Scale And Crop Without Caching Temp Image

04.07.2005
| 8042 views |
  • submit to reddit
        
def scale_crop
.......
   	
# Open the image-file
	   	img = Image.read(picture_name).first
		scale_image = img.scale(scale_width,scale_height )
		crop_image = scale_image.crop(left_x, left_y, right_x, right_y)
		@response.headers["Content-Type"] = "image/jpeg"
		render_text do |response|
            		print crop.to_blob
   		end
end