Convertion png to jpg leads to negative

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
Hubbitus
Posts: 66
Joined: 2010-05-04T10:50:21-07:00
Authentication code: 8675308
Location: Russia, Saint-Petersburg

Convertion png to jpg leads to negative

Post by Hubbitus »

Last edited by Hubbitus on 2011-12-11T15:06:14-07:00, edited 1 time in total.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Convertion png to озп leads to negative

Post by fmw42 »

Perhaps due to a cmyk jpg or something odd about your png.

Nevertheless, I cannot reproduce it on IM 6.7.4.0 Q16 Mac OSX Snow Leopard.

convert rose: rose.png
convert rose.png rose.jpg

rose.png and rose.jpg look the same (no negation).

What do you get for the above test?
Hubbitus
Posts: 66
Joined: 2010-05-04T10:50:21-07:00
Authentication code: 8675308
Location: Russia, Saint-Petersburg

Re: Convertion png to jpg leads to negative

Post by Hubbitus »

Could you please test it on images attached to mentioned bug too?
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: Convertion png to jpg leads to negative

Post by glennrp »

I think it's correct, but isn't what they were expecting.
The image (a.png a.k.a. q.png in the bug report) is grayscale, mostly transparent with black
antialiased lines. The JPEG encoder composes it over black (not negative).

Compare

Code: Select all

convert -size 567x794 xc:white a.PNG -flatten white.jpg
(what they expected) with

Code: Select all

convert -size 567x794 xc:black a.PNG -flatten black.jpg
(what they see)
Hubbitus
Posts: 66
Joined: 2010-05-04T10:50:21-07:00
Authentication code: 8675308
Location: Russia, Saint-Petersburg

Re: Convertion png to jpg leads to negative

Post by Hubbitus »

Thanks for the investigation in any case.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Convertion png to jpg leads to negative

Post by fmw42 »

Your image has an alpha channel. The alpha channel is essentially the negative of what you want. The underlying image is mostly fuzzy white outline. As jpg does not support transparency, all transparent areas turn black. So you need to flatten your image against the same color background that you normally present the image against. Lets say white. Then this will convert it properly (as Glenn pointed out)


convert a.png -background white -flatten a.jpg
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Convertion png to jpg leads to negative

Post by anthony »

Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply