ruby on rails - PaperClip 3.4: How to regenerate images is _original has been deleted? -
does know if possible tell paperclip use file other _original regenerate thumbnails from?
our _original files no longer available , want regenerate our thumbnails due style size change.
i'm not sure start looking on one.
alright, didn't test out extensively should work. assuming you're model defined as:
class image < activerecord::base has_attached_file :attachment, styles: { small: "300x300>", large: "100x100>" } end
this script use open-uri
treat urls file streams can pull large
style url, update model , reprocess each image.
require 'open-uri' image.find_each |image| large_image = open(image.attachment.url(:large)) {|f| f.read } image = large_image image.reprocess! end
again, did basic testing , i'm not 100% image =
assignment need more file stream, did test 1 image , seemed work. retained of existing image data , used large
style when reprocessing of existing image , added original.
hope helps. luck.
Comments
Post a Comment