
When saving images in general, and JPEG in particular, a colorspace is used. The two most commonly used colorspaces are RGB and CMYK. RGB is used for screens (e.g. television, monitors, phones). Screens work by combining different light colors (red, green or blue) into one color we can actually see. CMYK is used in print often. Instead of sending out light, paper must reflect light to give it color. If you check your own printer you’ll see there are three colors: cyan, magenta and yellow. Again, these three colors can be combined to absorb colors, and thus reflect the color you want. The problem is that not all web browsers are capable of handling JPEGs that use the CMYK colorspace. Internet Explorer is the most notorious one. Internet Explorer users will see an ‘image not found’-error - or red cross - instead. If you’re using thoughtbot’s Paperclip, the solution is easy. By adding some custom ImageMagick convert
options you can make sure that all generated thumbnails are in the RGB colorspace.
1
has_attached_file :avatar
would become:
1
2
has_attached_file :avatar
:convert_options => { :all => '-strip -colorspace RGB'}
Easy right? If you have a lot of CMYK images already, you don’t have to delete them, you can easily reprocess them when you made the above change:
1
User.find_each { |user| user.avatar.reprocess! }