There are numerous reports that Mobile Safari downsamples very large JPEG images, making it difficult to put out retina-friendly resolutions for the new iPad.
The solution seems to be encoding JPEGs as progressive/interlaced files. Hence, I'm curious how I might use the CarrierWave plugin, and RMagick by extension, to generate this type of file.
Thanks!
You can use MiniMagick:
manipulate! do |img|
img.strip
img.combine_options do |c|
c.quality "90"
c.depth "8"
c.interlace "plane"
end
img
end
As of today, you will need the repository version of carriewave as options[:write]
support is not yet released.
So in your Gemfile, use the following:
gem 'carrierwave', :github => "jnicklas/carrierwave"
Then, in your uploader you can define something like follow:
version :big do
process :resize_to_limit => [1024, 1024]
process :optimize
end
def optimize
manipulate! do |img, index, options|
options[:write] = {
:quality => 90, # Change the quality to 90%
:depth => 8, # Set the depth to 8 bits
:interlace => "Magick::PlaneInterlace" # Add progressive support for JPEG
}
img.strip! # Remove profile data
end
end
Useful reference : http://www.imagemagick.org/RMagick/doc/constants.html#InterlaceType
Enjoy!
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