re - preprocessing an image after first upload

200 views
Skip to first unread message

ScotterC

unread,
Jan 31, 2012, 3:38:19 PM1/31/12
to Dragonfly
Initially I only had an image_accessor in my model and was using
Dragonfly as it was meant to be used. It was wonderful.

Then, to increase some first time load times, I started preprocessing
some image sizes.

image_accessor :image do
copy_to(:large_image){|a| a.thumb('940x600') }
copy_to(:medium_image){|b| b.thumb('450x') }
copy_to(:small_image){|c| c.thumb('172x167#c')}
end

image_accessor :large_image
image_accessor :medium_image
image_accessor :small_image

Now I have instances of my model that do not have these new sizes (the
large, medium and small). In lieu of re uploading these images, is
there a way that I can reprocess them / copy & thumb them from the
command line? I haven't been able to call #copy_to from the image
attribute.

Thanks.

-Scott

Ajay Kumar

unread,
Feb 1, 2012, 2:48:06 AM2/1/12
to dragonf...@googlegroups.com
Scott,

I did exactly the same stuff. I had used  delayed_job and ran the processing in background as I has > 500k images. If the number of images that needs to be processed is less then probably you can do it from console.

You can find the code that I have used at https://gist.github.com/1715817

This code will convert the create the thumbnails for the existing images and all the new images that are assigned will automatically be resized based on the logic that you had.

Thanks,
Ajay

ScotterC

unread,
Feb 1, 2012, 11:08:49 AM2/1/12
to Dragonfly
Thanks. It's simpler then I thought. Didn't realize all processing
happened on save. I'm more familiar with Paperclip's method.

On Feb 1, 2:48 am, Ajay Kumar <aroopchan...@gmail.com> wrote:
> Scott,
>
> I did exactly the same stuff. I had used  delayed_job and ran the
> processing in background as I has > 500k images. If the number of images
> that needs to be processed is less then probably you can do it from console.
>
> You can find the code that I have used athttps://gist.github.com/1715817
Reply all
Reply to author
Forward
0 new messages