Why do PNG images have so much "extra" data?

General discussion about LÖVE, Lua, game development, puns, and unicorns.
User avatar
slime
Solid Snayke
Posts: 3172
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Why do PNG images have so much "extra" data?

Post by slime »

PNGs have several options for the type of data they contain (32 bit RGBA, 64 bit RGBA, 24 bit RGB, 8 bit greyscale, indexed palette, etc.)

PNGs also use the same type of compression (zlib/DEFLATE) that many zip files have - which supports various amounts of compression. Those factors allow for different PMG images that look the same to take up much different amounts of space.
User avatar
Jasoco
Inner party member
Posts: 3727
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Why do PNG images have so much "extra" data?

Post by Jasoco »

Well I just discovered one drawback to crushing my images. It removed all the opacity from my pixels. At least most of the image files.

Thankfully I have backups. Guess I'll go back. Didn't even notice it until now.
User avatar
pgimeno
Party member
Posts: 3688
Joined: Sun Oct 18, 2015 2:58 pm

Re: Why do PNG images have so much "extra" data?

Post by pgimeno »

Weird. I tried with pngcrush and trimage, and both preserved alpha. I start to wonder if ImageOptim does something else, e.g. quantization (creating indexed images with palette) like other lossy compressors do, e.g. pngquant.
User avatar
airstruck
Party member
Posts: 650
Joined: Thu Jun 04, 2015 7:11 pm
Location: Not being time thief.

Re: Why do PNG images have so much "extra" data?

Post by airstruck »

More likely it stripped out a tRNS chunk that was being used in an indexed image. Pngquant does a good job of preserving alpha, but indexed images need the tRNS chunk for that, and since tRNS is considered ancillary something that strips out chunks might get rid of it.

That's not something pngcrush would normally do without being asked, but maybe these frontends are more aggressive about removing chunks?
User avatar
Jasoco
Inner party member
Posts: 3727
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Why do PNG images have so much "extra" data?

Post by Jasoco »

Well apparently there's preferences for this app. And there's a lot of settings in here. I'll have to play around and see if one controls what happened. There's a quality setting too actually.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 4 guests