jtescher / carrierwave-imageoptimizer

This gem allows you to simply optimize CarrierWave images via jpegoptim or optipng.
https://rubygems.org/gems/carrierwave-imageoptimizer
MIT License
212 stars 33 forks source link

Is there an option to keep the original image file? #12

Closed devhyunjae closed 9 years ago

devhyunjae commented 9 years ago

Thanks for the awesome rubygem!

I have a little question. I want to optimize the image and also want to keep the original image.

and i coded like this,

class ImageUploader < CarrierWave::Uploader::Base
  process :optimize
  version :original
end

i was excepting two files

(optimized) uploaded_file.jpg original_uploaded_file.jpg but unfortunately, the original versioning is working with the image that already has been optimized :(

or is there an optimize option like this?

  process optimize: [keep_original: true]
elsurudo commented 7 years ago

@devhyunjae Have you figured this out? I would also like to keep the original file.

jtescher commented 7 years ago

You can process versions just as you would run any other processing in carrierwave, so if you want to only process a different version move the process :optimize line into your version block. E.g.

class ImageUploader < CarrierWave::Uploader::Base
  # Processing you want done on original here

  version :thumb do
    # Processing you want done on thumbnail here
    process :optimize
  end
end