thoughtbot/paperclip — Issue #773: Monochromatic images after upgrading from 2.3.16
Author: mmustala
Created: 2012-03-06 20:24:35+00:00
State: open

Hi,

After upgrading the paperclip to the newest version 2.7.0 all the images I attach to a model are converted to their monochromatic versions. The color that is picked for the image is about a median color used in the attached image. For example if I upload an image which is mainly red, the resulting image would be all red.

These are my configurations in the model. I think my paperclip started to work without any other configurations back then when I installed it the first time. So this is all paperclip specific configurations there is.

has_attached_file :photo, :styles => { :thumb => "40x40#", :small => "80x80#", :normal => "120x120#", :original => "1x1" },
:default_url => "/images/defaults/:style.png",
:url => "/images/candidates/:id/:style.:extension",
:path => ":rails_root/public/images/candidates/:id/:style.:extension"

Do you have any idea why this would be happening?

From the logs I can find that when using the 2.7.0 version it produced these lines when trying to upload an image.

Started PUT "/candidates/1/add_photo" for 127.0.0.1 at 2012-03-06 21:40:08 +0200
Processing by CandidatesController#add_photo as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"Kb30bOzVF1UwUQh1BnOg2JW1stl3inRojDeBeq5ULZY=", "candidate"=>{"photo"=>#>}, "commit"=>"Tallenna", "id"=>"1"}
User Load (0.3ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 LIMIT 1
Candidate Load (0.4ms) SELECT `candidates`.* FROM `candidates` WHERE `candidates`.`id` = 1 LIMIT 1
Command :: identify -format %wx%h '/tmp/stream20120306-2273-15mu2g8.jpg[0]'
Command :: convert '/tmp/stream20120306-2273-15mu2g8.jpg[0]' -resize "1x1" '/tmp/stream20120306-2273-15mu2g820120306-2273-1prvplz'
Command :: identify -format %wx%h '/tmp/stream20120306-2273-15mu2g820120306-2273-1prvplz[0]'
Command :: convert '/tmp/stream20120306-2273-15mu2g820120306-2273-1prvplz[0]' -resize "40x" -crop "40x40+0+0" +repage '/tmp/stream20120306-2273-15mu2g820120306-2273-1prvplz20120306-2273-167e2rg'
Command :: identify -format %wx%h '/tmp/stream20120306-2273-15mu2g820120306-2273-1prvplz[0]'
Command :: convert '/tmp/stream20120306-2273-15mu2g820120306-2273-1prvplz[0]' -resize "80x" -crop "80x80+0+0" +repage '/tmp/stream20120306-2273-15mu2g820120306-2273-1prvplz20120306-2273-b1dz6s'
Command :: identify -format %wx%h '/tmp/stream20120306-2273-15mu2g820120306-2273-1prvplz[0]'
Command :: convert '/tmp/stream20120306-2273-15mu2g820120306-2273-1prvplz[0]' -resize "120x" -crop "120x120+0+0" +repage '/tmp/stream20120306-2273-15mu2g820120306-2273-1prvplz20120306-2273-1eg1s8v'
(0.2ms) BEGIN
(3.6ms) SELECT 1 FROM `candidates` WHERE (`candidates`.`number` = BINARY 2 AND `candidates`.`id` != 1 AND `candidates`.`election_id` = 4 AND `candidates`.`region_id` = 146) LIMIT 1
(0.8ms) SELECT 1 FROM `candidates` WHERE (`candidates`.`user_id` = BINARY 1 AND `candidates`.`id` != 1 AND `candidates`.`election_id` = 4) LIMIT 1
Region Load (0.3ms) SELECT `regions`.* FROM `regions` WHERE `regions`.`id` = 146 ORDER BY name asc LIMIT 1
(0.7ms) UPDATE `candidates` SET `photo_file_name` = 'mika120vs100.jpg', `photo_content_type` = 'image/jpeg', `photo_file_size` = 336, `photo_updated_at` = '2012-03-06 19:40:08', `updated_at` = '2012-03-06 19:40:09' WHERE `candidates`.`id` = 1
[paperclip] Saving attachments.
[paperclip] saving /home/mika/projects/vaalikone/public/images/candidates/1/original.jpg
[paperclip] saving /home/mika/projects/vaalikone/public/images/candidates/1/thumb.jpg
[paperclip] saving /home/mika/projects/vaalikone/public/images/candidates/1/small.jpg
[paperclip] saving /home/mika/projects/vaalikone/public/images/candidates/1/normal.jpg

But when using 2.3.16 it only produces

Started PUT "/users/1" for 127.0.0.1 at 2012-03-06 22:17:32 +0200
Processing by UsersController#update as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"Kb30bOzVF1UwUQh1BnOg2JW1stl3inRojDeBeq5ULZY=", "user"=>{"alias"=>"", "region_id"=>"", "description"=>""}, "photo"=>#>, "commit"=>"Päivitä Käyttäjä", "id"=>"1"}
... Some unrelated sql queries ...
[paperclip] Saving attachments.
[paperclip] deleting /home/mika/projects/vaalikone/public/images/candidates/1/original.jpg
[paperclip] deleting /home/mika/projects/vaalikone/public/images/candidates/1/thumb.jpg
[paperclip] deleting /home/mika/projects/vaalikone/public/images/candidates/1/small.jpg
[paperclip] deleting /home/mika/projects/vaalikone/public/images/candidates/1/normal.jpg
[paperclip] saving /home/mika/projects/vaalikone/public/images/candidates/1/original.JPG
[paperclip] saving /home/mika/projects/vaalikone/public/images/candidates/1/thumb.JPG
[paperclip] saving /home/mika/projects/vaalikone/public/images/candidates/1/small.JPG
[paperclip] saving /home/mika/projects/vaalikone/public/images/candidates/1/normal.JPG

The image can be edited from two different views. Just to mention if you wondered about the difference in controller and action.