Author Topic: PNG optimization  (Read 9217 times)

Offline Scott_AW

  • Mr. Polyvector
  • ***
  • Posts: 214
    • View Profile
    • SAW Game Design
PNG optimization
« on: 2010-Feb-01 »
http://advsys.net/ken/utils.htm

Ken, creator of Duke3d's build engine has a useful PNG optimization program that can help reduce your overall graphical resource impact, although I doubt it will have any effect on game/program performance.  Could be ideal for porting to devices that have limits on storage space or generally keeping your program's resources smaller.
Current Project, Orbital Contract Defense
http://gamejolt.com/games/adventure/code-name-ocd/9887/

BlackShadow now open source/resource(requires duke3d)
http://gamejolt.com/games/adventure/black-shadow-3d/9885/

Offline Ian Price

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 4147
  • On the shoulders of giants.
    • View Profile
    • My Apps
Re: PNG optimization
« Reply #1 on: 2010-Feb-01 »
Silly question, but does reducing the file size of an optimised .PNG actually make any difference in a zipped file? I bet it doesn't.

The reason I ask is that a .BMP when zipped is generally smaller (sometimes significantly) than the same image in .PNG format so technically, reducing a .PNG only saves memory when extracted. For a smaller download, .BMP is often better. So it all depends when and where you want to make an image's memory size smaller.
I came. I saw. I played.

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10714
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: PNG optimization
« Reply #2 on: 2010-Feb-01 »
AFAIK, the PNG internally just does zip up the image line by line (thus slighlty better compression of BMPs). The use of PNG compressors will reduce the colour space to 16 or 8 bit if possible w/o changing the resulting image.
Also, there's an option to change "close" pixel colours to slightly different ones that seem to be better compressible.

Offline Ian Price

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 4147
  • On the shoulders of giants.
    • View Profile
    • My Apps
Re: PNG optimization
« Reply #3 on: 2010-Feb-01 »
Actually Gernot, PNG compression is worse than .BMP compression.

Try it - choose any large image. Save in .BMP and .PNG. Now compress the .BMP in .RAR or .ZIP - the compressed .BMP image will be smaller than the uncompressed .PNG image. Compress the .PNG image and the compressed .BMP will still be smaller.

.BMP compresses better than .PNG pretty much every time.
I came. I saw. I played.

Offline Moru

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1775
    • View Profile
    • Homepage
Re: PNG optimization
« Reply #4 on: 2010-Feb-02 »
Ever tried 7zip with bmp? :-)
« Last Edit: 2010-Feb-02 by Moru »

Offline Ian Price

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 4147
  • On the shoulders of giants.
    • View Profile
    • My Apps
Re: PNG optimization
« Reply #5 on: 2010-Feb-02 »
Ever tried 7zip with bmp? :-)

Nope - I always use WinRAR.
I came. I saw. I played.

phupost

  • Guest
Re: PNG optimization
« Reply #6 on: 2010-Mar-13 »
thanks 4share

Offline Hooka

  • Mc. Print
  • *
  • Posts: 3
    • View Profile
Re: PNG optimization
« Reply #7 on: 2010-Apr-18 »
Ian Price: What I think Kitty Hello is trying to say is that .PNG themselves have a better compression algorythm, making a PNG itself better compressed than a BMP, not better TO compress ;)

Offline Ian Price

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 4147
  • On the shoulders of giants.
    • View Profile
    • My Apps
Re: PNG optimization
« Reply #8 on: 2010-Apr-18 »
Sorry, Hooka, but that is not correct, or what I was saying.

It's obvious that an unzipped .PNG is smaller than an unzipped .BMP (that both have the same image). But just zip up the .BMP and leave the .PNG as it was and the zipped .BMP will generally be smaller than the .PNG.

Therefore .PNG compression IS NOT better than .BMP compression. I have tried this with multiple images of varying sizes and 99% of the time a zipped .BMP will be smaller than either a zipped or unzipped .PNG.
I came. I saw. I played.

Offline Moru

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1775
    • View Profile
    • Homepage
Re: PNG optimization
« Reply #9 on: 2010-Apr-18 »
Todays compression algorithms are usually best applied once. If you compress something already compressed you will most of the time not get a better result. More likely a worse result. So if you want a small distribution package, go for BMP, if you want small size on the installed game, use PNG with compression. On the other hand, most people don't care about either nowadays with flatrate 100 Mbit internet connection and 2 x 1.5 Terrabyte harddrives... :-)

But whatever format you choose, the memory footprint will be roughly the same when running your game.

Offline Ian Price

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 4147
  • On the shoulders of giants.
    • View Profile
    • My Apps
Re: PNG optimization
« Reply #10 on: 2010-Apr-18 »
Indeed, once in the game the memory used will be the same - it's just small size for distribution or small size on your HD/memory card.
I came. I saw. I played.

Offline Kuron

  • Mr. Polyvector
  • ***
  • Posts: 238
    • View Profile
Re: PNG optimization
« Reply #11 on: 2010-Apr-19 »
Quote
So if you want a small distribution package, go for BMP, if you want small size on the installed game, use PNG with compression. On the other hand, most people don't care about either nowadays with flatrate 100 Mbit internet connection and 2 x 1.5 Terrabyte harddrives... :-)
Bloat because you can is never good and it matters now, more than it ever has before.

Offline Moru

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1775
    • View Profile
    • Homepage
Re: PNG optimization
« Reply #12 on: 2010-Apr-19 »
I cared about it a lot more when I had a 300 baud modem than now when I have 100 Mbit... If a download is 4 MByte or 750 MByte doesn't do that much difference in time any more. And in the case of 750 MByte it's most likely a linux distro so I can just burn it and delete it. Next time I need it I need to download a new one anyway since it was updated again :-)

Offline Kuron

  • Mr. Polyvector
  • ***
  • Posts: 238
    • View Profile
Re: PNG optimization
« Reply #13 on: 2010-Apr-19 »
Moru:  Not everybody has 100Mbit connections.  Many of those who do, can't actually use them.  Many in Europe still do not have unlimited bandwidth ISPs.  Some of the ISPs that offer unlimited bandwidth have caps in the small print of the ToS.  It is not any different here in the USA.

You also need to remember many of the systems our EUs are using are systems that have limitations similar to 10 year old systems.  Netbooks are a huge market, and people do play games on them.  Many of the original netbooks out there only have 4GB- 8GB hard drives drives.   Most current models now have 120GB-160GB hard drives, but that is still pretty small by the time you put Windows and a few office apps on it, there isn't room for a lot of games.  Desktops are no different.  People are increasingly moving to SSDs.  The affordable and reputable SSDs are around 80GB.  Extremely limited space.  GLBasic games will run fine on any of the systems mentioned in this paragraph.  The only thing at a premium is space.

Also, EUs are increasingly moving to portable apps.  Again, limited space on portable drives.

Tablets are making a comeback, but with reduced capacity.

Distribution size for games and apps should be a major concern for developers.  It will continue to be a concern in the future as long as technology continues to progress via addition by subtraction.

Offline Moru

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1775
    • View Profile
    • Homepage
Re: PNG optimization
« Reply #14 on: 2010-Apr-19 »
Yes, I guess I'm still in the stone age being spoiled since 10+ years with 100MBit internet here in the forests of northern Sweden :-)

And the sort of applications I do, grafics are such a low concern that it won't change the size of the app much...