I could encode images in Progressive JPEG by doing the following for my CarrierWave downloader:
class ImageUploader < CarrierWave::Uploader::Base include CarrierWave::MiniMagick process :optimize
You must place the last process that converts the image to Progressive JPEG, otherwise it will not be converted.
Then, if you have already uploaded some images and want to recreate them. Imagine your model:
class Picture < ActiveRecord::Base mount_uploader :image, ImageUploader end
So, you must do the following to recreate the versions:
Picture.order("id ASC").each do |p| p.image.recreate_versions! puts "#{p.id}, #{p.image.url}" end
I ordered an image based on the identifier, because if it did not go in the middle of the process, I have an identifier, and I can continue with this ID. Another thing you can do is to save any exception and save photos that do not work in an array, something like this:
errored = [] Picture.order("id ASC").each do |p| begin p.image.recreate_versions! rescue => e errored << p.id end puts "#{p.id}, #{p.image.url}" end
Finally, to verify that the image was converted to Progressive JPEG, with ImageMagick installed, enter the following into the terminal:
identify -verbose PATH_TO_IMAGE | grep Interlace
If the image is a progressive JPEG, the output will be Interlace: JPEG , if not Interlace: None