2

This is a similar question to this.

I have a GalleryPhoto model with ~28,000 records. Each has an image attachment with five styles: original, large, medium, small, and thumb. The large, medium, and small have a watermark applied to them. I want to add an addition style called download to the styles that has no watermark.

How can I reprocess the entire batch to only add the additional style without redoing all of the existing styles? Otherwise the reprocess will probably take days.

Rails 3.1.1
Paperclip 2.4.2
ImageMagick 6.2.8
Community
  • 1
  • 1
Preacher
  • 2,410
  • 1
  • 19
  • 29

1 Answers1

0

Here is what I did in console, and it seems to be working quite well.

GalleryPhoto.order('id DESC').each do |record|
  original_style_name = "original_#{record.image_file_name}"
  new_style_name = "small_download_#{record.image_file_name}"
  image_path = "#{Rails.root}/private/images/galleries/#{record.gallery_id}/#{record.id}"
  system "cd #{image_path} && cp #{original_style_name} #{new_style_name} && mogrify -resize 600x600 #{new_style_name}"
  puts record.id
end
Preacher
  • 2,410
  • 1
  • 19
  • 29