Optimizing PNG files (by ~45% for OpenTTD) - FIXED

Discuss, get help with, or post new graphics for TTDPatch and OpenTTD, using the NewGRF system, here. Graphics for plain TTD also acceptable here.

Moderator: Graphics Moderators

Post Reply
CobraPL
Engineer
Engineer
Posts: 12
Joined: 13 Mar 2009 23:45

Optimizing PNG files (by ~45% for OpenTTD) - FIXED

Post by CobraPL »

Greetings,

I optimized (losslessy) and attached to this post PNG files from OpenTTD 0.7.0 beta 2
I used script and programs from Hydrogenaudio thread with "--insane" switch. EDIT: currently, I used only PNGOUT application. Script has flaws.

Old size: 116797
New size: 64609

For 10000 downloads it saves ~0.5Gb of traffic ;)

See also: Smaller ZIP/7z package (by from ~3.5% to ~28% for OpenTTD)

EDIT: Please redownload, there is a fixed version of "openttd.16.png" plus all files are even smaller.

Peter
Attachments
OpenTTD-PNGs-FIXED.zip
All files reoptimized !
(63.59 KiB) Downloaded 125 times
Last edited by CobraPL on 16 Mar 2009 00:58, edited 8 times in total.
Rubidium
OpenTTD Developer
OpenTTD Developer
Posts: 3815
Joined: 09 Feb 2006 19:15

Re: Optimizing PNG files (by ~45% for OpenTTD)

Post by Rubidium »

Your openttd.16.png is NOT the same as the openttd.16.png shipped with OpenTTD so somewhere in the conversion colours have been changed. Seems like the alpha blur at the sides of the logo has been lost.

Just compare them side by side in e.g. The GIMP.
CobraPL
Engineer
Engineer
Posts: 12
Joined: 13 Mar 2009 23:45

Re: Optimizing PNG files (by ~45% for OpenTTD)

Post by CobraPL »

Well, source files were the original ones. Palette is probably changed, so only 168 of used colors are in palette (not used ones are removed from palette). I double checked problem you described. Both with PAINT.NET and Gimp - pictures are identical, including alfa.

But... Just after installing GIMP I made stupid mistake and I dragged both files, one by one, into the same window which caused effect, that second file has darker alfa on corners. I simply added second file as new layer for first one.

Just launch GIMP, select FILE/NEW two times, so you will have TWO empty windows. Then drag and drop first file to one window, second to another, use 2000% magnify on both. You will see that these files are identical.
SmatZ
OpenTTD Developer
OpenTTD Developer
Posts: 351
Joined: 03 Oct 2006 18:26
Location: Prague, Czech Republic
Contact:

Re: Optimizing PNG files (by ~45% for OpenTTD)

Post by SmatZ »

Sorry, it really looks your image is missing the alpha channel
Attachments
notsame.png
(35 KiB) Downloaded 215 times
Image
CobraPL
Engineer
Engineer
Posts: 12
Joined: 13 Mar 2009 23:45

Re: Optimizing PNG files (by ~45% for OpenTTD)

Post by CobraPL »

SmatZ wrote:Sorry, it really looks your image is missing the alpha channel
STRANGE! I use GIMP 2.6.4 (see attachment). Not only both files are identical, but also are RGB, 2 layers. In your gimp left one is "indexed, 1 layer" and right one is "RGB, 1 layer". But we are talking about same files... Which version do you have? Did you tried another program ?
I think that we should see these icons in real life. I can't find, where these icons are used in the game. Anyway, I added proof that alfa works.

Optimized:
ImageImageImageImageImage

Original:
ImageImageImageImageImage
Attachments
TheSame.PNG
Huh?
(86.52 KiB) Downloaded 126 times
SmatZ
OpenTTD Developer
OpenTTD Developer
Posts: 351
Joined: 03 Oct 2006 18:26
Location: Prague, Czech Republic
Contact:

Re: Optimizing PNG files (by ~45% for OpenTTD)

Post by SmatZ »

It looks it has the alpha channel when opened in Firefox... I am not really a graphic, so I will leave that for someone else to explain :)
Image
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Re: Optimizing PNG files (by ~45% for OpenTTD)

Post by DaleStan »

8-bit indexed destroys the alpha channel, essentially by definition.
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
peter1138
OpenTTD Developer
OpenTTD Developer
Posts: 1791
Joined: 30 Mar 2005 09:43

Re: Optimizing PNG files (by ~45% for OpenTTD)

Post by peter1138 »

DaleStan wrote:8-bit indexed destroys the alpha channel, essentially by definition.
Not when you have an RGBA palette table.
Wikipedia wrote:For paletted images, alpha values can be added to palette entries. The number of such values stored may be less than the total number of palette entries, in which case the remaining entries are considered fully opaque.
He's like, some kind of OpenTTD developer.
User avatar
GeekToo
Tycoon
Tycoon
Posts: 961
Joined: 03 Jun 2007 22:22

Re: Optimizing PNG files (by ~45% for OpenTTD)

Post by GeekToo »

CobraPL wrote: Not only both files are identical, but also are RGB, 2 layers.
Incorrect, your .16.png file, unzipped from your first post is 8 bit indexed, the original (in my media folder) is rgba.
CobraPL wrote: In your gimp left one is "indexed, 1 layer" and right one is "RGB, 1 layer". But we are talking about same files... Which version do you have? Did you tried another program ?
I added proof that alfa works.
Incorrect again, you proved that transparency worked, by specifying in the palette that the first colour index should not be drawn (i.e. transparent).
But as DaleStan stated, you cannot specify the alfa value, i.e. make something 50% transparent. And exactly that is used in the originals to do some anti-aliasing on the edges. Because you can only specify 0% or 100% transparency, the edges will look jaggy.
CobraPL
Engineer
Engineer
Posts: 12
Joined: 13 Mar 2009 23:45

Re: Optimizing PNG files (by ~45% for OpenTTD)

Post by CobraPL »

GeekToo wrote:
CobraPL wrote: Not only both files are identical, but also are RGB, 2 layers.
Incorrect, your .16.png file, unzipped from your first post is 8 bit indexed, the original (in my media folder) is rgba.
My GIMP shows RGB, 2 layers, you have it on the screenshot.
GeekToo wrote:
CobraPL wrote: In your gimp left one is "indexed, 1 layer" and right one is "RGB, 1 layer". But we are talking about same files... Which version do you have? Did you tried another program ?
I added proof that alfa works.
Incorrect again, you proved that transparency worked, by specifying in the palette that the first colour index should not be drawn (i.e. transparent).
But as DaleStan stated, you cannot specify the alfa value, i.e. make something 50% transparent. And exactly that is used in the originals to do some anti-aliasing on the edges. Because you can only specify 0% or 100% transparency, the edges will look jaggy.
If you have right, why both images look identical (which I shown already), including transparency - in this thread, in my GIMP, in my Paint.net ? I dont't know technically what was changed, I know, that files are smaller and look identical. No anti-aliasing is lost, which you can see in this thread - maybe it is lost in old GIMP version. Of course, DEVs should have backup of original files, but I think, that distributable version should be the optimized one.

Also i checked transparency - it is >0 and <100

By the way, I have two questions:
1) Where are these PNGs used? I know, that these files are stored in \media\ but where in game?
2) What will go wrong if optimized version will be in package? Who will not see anti-aliasing or alpha channel and where ? I mean in real life. So far I know about (outdated?) version of GIMP - my version shows everything ok.

Hmm...
Attachments
50% transparency ?
50% transparency ?
50%.png (129.22 KiB) Viewed 876 times
User avatar
GeekToo
Tycoon
Tycoon
Posts: 961
Joined: 03 Jun 2007 22:22

Re: Optimizing PNG files (by ~45% for OpenTTD)

Post by GeekToo »

Your 256.png seems to be ok, but I was asking to look at the openttd.16.png file (and also Rubidium did).

That one is not ok. Both Photoshop and Irfanview see it as an 8bpp indexed file. So load your zip file from the first post, unpack it, and try again.
CobraPL
Engineer
Engineer
Posts: 12
Joined: 13 Mar 2009 23:45

Re: Optimizing PNG files (by ~45% for OpenTTD)

Post by CobraPL »

GeekToo wrote:Your 256.png seems to be ok, but I was asking to look at the openttd.16.png file (and also Rubidium did).

That one is not ok. Both Photoshop and Irfanview see it as an 8bpp indexed file. So load your zip file from the first post, unpack it, and try again.
Please, try fixed version from the first post. Opimizing script has a flaw(s) - sometimes files are bigger after optimization. Espiecially small ones.

Please check current version of PNGs. If everything is OK, please consider adding these files to 0.7.0.
User avatar
GeekToo
Tycoon
Tycoon
Posts: 961
Joined: 03 Jun 2007 22:22

Re: Optimizing PNG files (by ~45% for OpenTTD) - FIXED

Post by GeekToo »

Looks ok to me now :)
Post Reply

Return to “Graphics Development”

Who is online

Users browsing this forum: No registered users and 13 guests