chaiNNer-org / chaiNNer

A node-based image processing GUI aimed at making chaining image processing tasks easy and customizable. Born as an AI upscaling application, chaiNNer has grown into an extremely flexible and powerful programmatic image processing application.
https://chaiNNer.app
GNU General Public License v3.0
4.52k stars 279 forks source link

PNG Compression Support #2608

Open Codinablack opened 7 months ago

Codinablack commented 7 months ago

Motivation The main reason is storage!

Description The save image node should support controlled compression level for png files just like it does with jpeg and webp.

RunDevelopment commented 7 months ago

Sorry, but I don't understand what you want. Image compression is already implemented by the Save Image node, so I'm not sure what you're suggesting here.

Codinablack commented 7 months ago

Sorry, but I don't understand what you want. Image compression is already implemented by the Save Image node, so I'm not sure what you're suggesting here.

Where do you see the option for compression?

image

Please show me where I overlooked the ability to run a compression algorithm to make the saved image smaller, is it supposed to be the channels option?

Here you can see something along the lines of what I am requesting. image

Notice there are tabs for "resizing" which changes the dimensions thereby reducing size (which is not what I am looking for) and there is a tab for adjusting how much quality is kept during compression (this is what I am looking for), which allows me to drop a 6.6mb 1536x1536 picture down to a 656kb 1536x1536 picture with no noticeable difference in quality.

I don't know how I could have been more clear with what it is I am requesting, I literally describe it in detail! The feature that I am asking for does not already exist as far as I know, and most certainly doesn't exist in the "Save Image" node.

Codinablack commented 7 months ago

To be clear, if you look up "Image compression" you will find confusing results, most mention reducing its "size" and often do so by literally down-scaling the dimensions of a given image, this is not at all what I am asking for as it already exists as an option with the "resize" node.

I am talking about this: image

joeyballentine commented 7 months ago

Ah, we support compression for jpeg, webp, and DDS. The reason we don't support it for PNG right now is because of opencv, which we use for image saving. The default compression is way faster that the other compression alpgrothms, and IIRC also produces a decently small file size, so we figured it wasn't worth users shooting themselves in the foot slowing down the workflows for a worse result anyway.

We could potentially switch off of opencv, but whatever we switch to would need to be just as fast.

RunDevelopment commented 7 months ago

Where do you see the option for compression?

PNG, JPEG, and WebP images created by Save Images are always compressed. We just don't offer an option to control the compression for PNG. The JPEG and WebP quality options become visible once the respective format is selected.

Here you can see something along the lines of what I am requesting.

First time I heard of Caesium. It's awesome. The base library is also written in Rust, so it would be possible for us to support. However, we already support compression options for JPEG and WebP, so only PNG would be interesting.

And about Caesium's PNG quality: it's the first time I heard about lossy PNG compression. The trick is that they lower the bit depth and dither. This is very unusual, because JPEG/WebP can generally achieve better quality for the same size when it comes to lossy compression. So I'm unsure how much value there is in even supporting lossy PNG compression.

Codinablack commented 7 months ago

I suppose I could try saving to webp and then convert to png later to save on my storage. I didn't realize that there were different options for different formats. I will change everything to make it reflect an issue for png compression support.