I have a model that uses Paperclip to handle images. When the image gets uploaded a preview is made for some javascript cropping and then a thumbnail and preview sizes are made from the chosen cropping. Giving us 3 images on S3 total:
- Original Image
- Preview (from the user selected cropping)
- Thumb (from the user selected cropping)
The code in the model for the attachment is:
has_attached_file :picture, ASSET_INFO.merge(
:whiny => false,
:styles => { :thumb => '200>x200#', :preview => '400x300>' },
:processors => [:jcropper],
:preserve_files => true
)
We have some functionality that allows a user to make a copy of an object for their own purposes and we want to copy the images over. I thought that just doing a simple
new_my_model.picture = original_my_model.picture if original_my_model.picture_file_name #no file name means no picture
would get the job done, and it does, but only kind of.
It's copying the picture and then reprocessing the preview and thumbnails based on what's set up in the model.
What I would like to do instead is copy all 3 existing images (original, thumb, and preview) to the new object as they are for the original one and then save them in the appropriate location on S3, skipping the resizing/cropping.
Can anyone point me in the right direction? I've searched online and can't seem to find anything and everything I try doesn't seem to work. Doing a .dup
on the original picture causes an exception, so that idea is out.