How do I tell Paperclip not to save the original file when it is uploaded? Or even better, to store a scaled version of the file as the original?
I believe that you can simply define a style for :original to have paperclip replace the original with that size.
:styles => { :original => '300x168>', :cropped_thumb => {:geometry => "115x70#", :jcrop => true}, ...}
Cris G's solution may be nice at most simple cases but it has limitations. consider that: style :original Paperclip process first of all others, so after that updated :original image (much smaller now) will be the source for following processing. Hence you are forced to keep :original style as best-resolutioned. The situation comes worse as you need to crop images with processor: that is the situation where you really need for real original quality. )
So I would recommend you somewhat raw (need to find out how to get every attachments of the model) solution:
after_save :reprocess_attach
private
def reprocess_attach
if self.<atch_name>.present? && Pathname.new(self.<atch_name>.path).exist?
self.<atch_name>.save
File.unlink(self.<atch_name>.path)
end
end
it doesn't care about what processing was behind the stage. It just kills original file )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With