Can gif image have same quality as PNG image?

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
agriz
Posts: 237
Joined: 2011-10-01T02:21:30-07:00
Authentication code: 8675308

Can gif image have same quality as PNG image?

Post by agriz »

Code: Select all

convert any.png any.gif
Both are having different quality. fuzz, -layers OptimizePlus are not proving good results.
For transparency we can use some matching background color. But the whole image is not as good as png.

What is the best solution?
Image
Image
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Can gif image have same quality as PNG image?

Post by Bonzo »

I would guess your problem is a gif is limited to 256 colours.
agriz
Posts: 237
Joined: 2011-10-01T02:21:30-07:00
Authentication code: 8675308

Re: Can gif image have same quality as PNG image?

Post by agriz »

What does it mean? How can i fix that problem?
agriz
Posts: 237
Joined: 2011-10-01T02:21:30-07:00
Authentication code: 8675308

Re: Can gif image have same quality as PNG image?

Post by agriz »

How many colors do png support when comparing with gif?
Is there any solution for this? I have seen good gif images.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Can gif image have same quality as PNG image?

Post by Bonzo »

From what I have read .png images can have 256 trillion colours.
agriz
Posts: 237
Joined: 2011-10-01T02:21:30-07:00
Authentication code: 8675308

Re: Can gif image have same quality as PNG image?

Post by agriz »

256 trillion vs just 256 colors?
Is it imagemagick or general?
How come images are good in gif?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Can gif image have same quality as PNG image?

Post by snibgo »

Each pixel in a 16-bit/channel/pixel PNG file can be one of 2^48 = 281,474,976,710,656 different colours.

Each pixel in a GIF file can be one of 256 different colours. This isn't quite as bad as it sounds, because each of those colours is chosen from a list of 2^24 = 16,777,216 colours. Provided the image is fairly simple, and the 256 colours are chosen intelligently, and we don't look closely, GIF isn't too bad.

These are limits of the file formats, nothing to do with ImageMagick.

If we are counting colours, pixels in a 32-bit/channel/pixel TIFF file can be one of 2^(32*3) = 79,228,162,514,264,337,593,543,950,336 different colours.
snibgo's IM pages: im.snibgo.com
agriz
Posts: 237
Joined: 2011-10-01T02:21:30-07:00
Authentication code: 8675308

Re: Can gif image have same quality as PNG image?

Post by agriz »

GIF is not too bad. But it is not as good as png. I never used TIFF. It must be super!
If i work with lower quality images, the output gif is really bad. :(
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Can gif image have same quality as PNG image?

Post by snibgo »

The human eye can distinguish only about 100 levels per channel, so an 8-bit/channel/pixel image is usually good enough, as a final output image. But if we need to process the image, the processing might lose a few bits, so we want the best possible input image.

I do a huge amount of varied image processing, and the only time I need 32-bit/channel/pixel is when those "images" are really displacement maps.
snibgo's IM pages: im.snibgo.com
agriz
Posts: 237
Joined: 2011-10-01T02:21:30-07:00
Authentication code: 8675308

Re: Can gif image have same quality as PNG image?

Post by agriz »

Original Image : JPEG
Image

ImageMagick
Image

Photoshop
Image

Photoshop is looking better than Imagemagick.
How?

I converted few images to gif but they are really worst. There should be an option to improve it.

Original
Image
Photoshop
Image
Imagemagick
Image
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Can gif image have same quality as PNG image?

Post by snibgo »

You have a reasonable JPG image that has 64932 different colours. From that, you make a GIF image that has far fewer colours and a larger filesize (more bytes). Why? What are you trying to do?
snibgo's IM pages: im.snibgo.com
agriz
Posts: 237
Joined: 2011-10-01T02:21:30-07:00
Authentication code: 8675308

Re: Can gif image have same quality as PNG image?

Post by agriz »

Sir, I am animating them.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Can gif image have same quality as PNG image?

Post by snibgo »

For best-quality animated GIFs from a series of photos, I suggest you use ffmpeg, not ImageMagick.
snibgo's IM pages: im.snibgo.com
agriz
Posts: 237
Joined: 2011-10-01T02:21:30-07:00
Authentication code: 8675308

Re: Can gif image have same quality as PNG image?

Post by agriz »

No. I need to composite images and add effectss
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Can gif image have same quality as PNG image?

Post by snibgo »

Yes, you can process the individual frames with IM. You can do that with maximum bit depth, to keep the quality high. When you want to assemble the frames into a GIF, I suggest you use ffmpeg for that processing.
snibgo's IM pages: im.snibgo.com
Post Reply