PNG compression

Nottravis

Sci-fi Smutress
Donor
Game Developer
Jun 3, 2017
5,132
27,280
Chaps,

A, hopefully, quick one.

I'm planning on dropping my game on here a few days after Christmas and I'm suddenly aware that she's on the large size due to the number of images.

Any views on the best method/tool for compressing PNGs?

Thanks
 

bas

retired
Donor
Respected User
Former Staff
May 6, 2017
3,988
30,555
Chaps,

A, hopefully, quick one.

I'm planning on dropping my game on here a few days after Christmas and I'm suddenly aware that she's on the large size due to the number of images.

Any views on the best method/tool for compressing PNGs?

Thanks
My tool is in my sig, but for your main game release, I suggest you use Sam's webpy tool so you can go with lossless webp. Better quality.
 

f95zoneuser463

Member
Game Developer
Aug 14, 2017
219
1,024
I disagree with WEBP having 'minimal quality loss' after having tested multiple tools and settings to encode to this format. Lossless is good and beats PNG in compression. But lossy WEBP compression, even at the highest quality settings, has very visible quality loss. The images tend to be blurry. This is due to the format using a lower precision color-space (YCbCr) and 4:2:0 chroma subsampling. I'm not an expert on color-spaces, from what I've seen especially red-tones tend to have visible artifacts. I guess these arifacts are a result of this being a block based encoding in combination with the chroma subsampling. The lossless compression does not have this problem. It uses RGB. Another pitfall with this format are the settings for encoding transparent images, incorrect setting can f*ck up even lossless WEBP's and some GUI based tools don't even show these important settings.

For brute force PNG compression:
is a relatively fast
is slower but compresses better (best compression as far as I know)
I use both in one script because pngcrush automatically strips unnecessary alpha-channels and then pngout gives the best compression. I've automated cropping overlays and use metadata in PNG's to store the image-positions for Ren'Py inside the image.

Edit: A only.

I'm still looking for brute force WEBP tools, especially for lossless compression. There seems to be no such thing.
 
  • Like
Reactions: Nottravis

Nottravis

Sci-fi Smutress
Donor
Game Developer
Jun 3, 2017
5,132
27,280
Thank you all so very much.

So the best method may well depend upon the original colours used in the PNGs?

Well no harm in me trying them all out and seeing which works best for Chapter 1.

Thank you once again.
 

kaboomer69

Member
Sep 1, 2018
258
1,191
You can try Irfanview, it has some plugin to set size limits for JPG / PNG which automatically picks the highest possible quality.
Of course with batch conversion and renaming.
 
  • Like
Reactions: swmas and Nottravis

Bip

Active Member
Donor
May 4, 2017
737
2,131
For mac, we have a very good and light . For PNG compression (lossless or not), it nearly always combines different compressors such as advPNG + PNGOut, oxiPNG + Zopfli etc. This means that it is sometimes (often?) necessary to use several compressors to obtain the best results.

I won't be able to advise you for Windows, but the ImageOptim site recommends in particular the free and open source which can handle many formats.
 

Nottravis

Sci-fi Smutress
Donor
Game Developer
Jun 3, 2017
5,132
27,280
Eek...so different compression methods for different systems too.

*adds to list of things to do!
 

FranceToast

Active Member
Donor
Jul 31, 2018
562
897
I'm kind of surprised the latest Photoshop CC still doesn't natively support WebP import/export. Also Google doesn't provide a Photoshop plugin, which seems like an easy way for them to help spread WebP as a standard, if that is their goal. There are two 3rd party plugins out there, one for CS5/6, and one supposedly for 'later' versions of Photoshop, but I haven't tried either of them yet.

I rarely use .PNG in Photoshop, just so used to JPEG, so it looks like I'll have to do a lot of experimenting.
 
  • Like
Reactions: Nottravis

Rich

Old Fart
Modder
Donor
Respected User
Game Developer
Jun 25, 2017
2,566
7,382
While PNG (or lossless WEBP) will give you the absolute best fidelity, as you've discovered it comes at a cost. Any form of lossy compression involves tradeoffs. Have you even experimented at all with converting to JPG? A high-fidelity JPG is hard to distinguish from a PNG, and will be a lot smaller.

I know there are folks that advocate strongly for WEBP over JPG - I'm not disparaging the WEBP format. But, as previous posters have indicated, tool support for it isn't as good as some other formats.

I guess the "best" approach all boils down to how much of a perfectionist you are about the images, and how the various tools perform for you.
 

redle

Active Member
Apr 12, 2017
625
1,093
Eek...so different compression methods for different systems too.

*adds to list of things to do!
Different tools exist on different platforms. True enough. Though don't confuse the tool with the end result. The final image is the size it is regardless of platform. Unless you frequently swap use between mac, windows, etc, there is no reason to start doing so simply for image size reduction. Use a tool on whichever platform you typically use.

As others have said, it will boil down to preference. How HD do you want your images to be. Because along with the compression and formats of the different file types, there is also always the basic, what are the image dimensions. You could create/scale all your pictures to 40 pixels by 40 pixels and no matter what format you use they would not take up much disk space. They can be scaled larger or left as is at viewing time. (I'm exaggerating the size to emphasize the point. I don't actually expect you to use chibi sized images for your main displays.) To some extent this is what some of the compressions are doing behind the scenes.
 
  • Like
Reactions: Nottravis

Nottravis

Sci-fi Smutress
Donor
Game Developer
Jun 3, 2017
5,132
27,280
Again, thank you all -so- much.

Like everything in life it's a balancing act. I tried out several options but ran with WebPy in the end as this -seemed- to not impact upon the quality too much whilst giving me a fair old bang for my buck in terms of size reduction. That said the images in Chapter one are fairly straightforward and it might be a case of "horses for courses" as the render backgrounds get more complex.

But with WebPy it knocked the size down from 1.6Gb to 865Mb so well worth it!
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,971
16,226
I guess the "best" approach all boils down to how much of a perfectionist you are about the images, and how the various tools perform for you.
I would add that it's not mandatory to stick to a single format. What matter is to keep a good ratio between quality and size, not to have the smallest size all the time.
Keep PNG for everything that is already small (mostly the user interface and buttons), then decide between JPG/WebP case by case. It will need more time at first, but with the experience you'll be able to assume that "this picture will look better in JPG, but for this one lossy WebP will not mess too much". Even PNG can be a good option if the image many uniform surfaces.
And like Ren'py don't use the file extension to find the file format, you can even change your mind between two updates, without the need to change something in your code.
 
  • Like
Reactions: Rich

gamersglory

Xpression Games
Donor
Game Developer
Aug 23, 2017
1,356
3,562
Jpg is a lossless standard by nature no point in using it if your looking for the best results
 

HiEv

Member
Sep 1, 2017
384
785
Jpg is a lossless standard by nature no point in using it if your looking for the best results
I believe you mean "JPEG is a lossy standard by nature", not "lossless".

That said, in most image editing software capable of saving JPEGs you have a lot of control over the compression level. If you know what you're doing, you can get very high quality results for most JPEG images, while also getting a lot more compression than you can get from other image formats.

It's a mistake to completely write off the JPEG format merely because it's lossy. Often the "loss" comes in areas that the human eye won't notice, such as the million different shades our eyes lump all together as "black".

I'm not saying that there aren't situations where other formats are better, but when you consider that the size of the download can affect how many people can/will play your game, "best results" is a lot more complicated than that.

(FYI, I worked for 7 years in the imaging industry, and at the time my email address ended in "jpg.com". :p )
 
  • Like
Reactions: f95zoneuser463