How to save cropped image of an image URL without saving the original image? (in Rails using Paperclip or other plug-ins)
Hi all
I have an app now showing photos from URL, not from my own da开发者_Python百科tabase (file system). For example, a photo from Facebook: http://sphotos.ak.fbcdn.net/hphotos-ak-snc1/hs085.snc1/5041_98423808305_40796308305_1960517_6704612_n.jpgI've added the crop function to get the cropping area (x,y,w,h) of the photo.
And now I'd like to save the cropped image from the URL (i.e. without downloading the original image to my database before cropping)Is it even possible?
Or is there anyway to get the image into memory to process without saving it to database? I've searched some questions here, but they all talk about how to save the crop of images which have been uploaded to the database by users.Thank you very much in advance.
How do you imagine cropping works without access to the original image? The process would be like this:
- Download the remote image to a /tmp as a temporary file (Tip:
TempFile
) - Crop the crap out of it
- Save the cropped image with Paperclip to your DB
- Remove the temporary file
精彩评论