About gif to jpg color distortion

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
beginner
Posts: 15
Joined: 2016-05-12T18:21:50-07:00
Authentication code: 1151

About gif to jpg color distortion

Post by beginner »

2.gif
Image

convert 2.gif -background white -flatten 2.jpg

2.jpg
Image


If you convert to a png image, the color will not be distorted

convert 2.gif -background white -flatten 2.png

2.png
Image


Why are the colors distorted when converted to jpg pictures?
What parameters convert.exe need to add to keep the jpg image color unchanged?

thanks
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: About gif to jpg color distortion

Post by fmw42 »

Gif has limited colors (<=256) and palette type. When converted to jpg with lossy compression, you introduce new colors and 24-bit color. You would have to create a color map image and use -recolor to try to get the same colors back in your jpg, though that may not work, since JPG does not support 8-bit total color.
beginner
Posts: 15
Joined: 2016-05-12T18:21:50-07:00
Authentication code: 1151

Re: About gif to jpg color distortion

Post by beginner »

Thanks for your tip.

When I set the image compression quality to 100, the color is no longer distorted.

Image
Post Reply