kornelski / pngquant

Lossy PNG compressor — pngquant command based on libimagequant library
https://pngquant.org
Other
5.25k stars 486 forks source link

--skip-if-larger should be on by default #338

Open varnav opened 5 years ago

varnav commented 5 years ago

I was quite surprised that after running program for image optimization with defaults I ended up with 30% of smaller images and 70% of larger images, and with bigger total.

--skip-if-larger must be default setting

XhmikosR commented 4 years ago

Agreed, this makes total sense

Ihornechypor commented 4 years ago

Hi, any info when it will be developed???

zvezdochiot commented 4 years ago

@varnav say:

--skip-if-larger must be default setting

So put it on.

https://github.com/kornelski/pngquant/blob/7ffdc41525d80461d1f581644fbf9df135140c67/pngquant_opts.c#L127-L129

to:

    int opt;
    options->skip_if_larger = true;
...
            case arg_skip_larger:
                options->skip_if_larger = !(options->skip_if_larger);
                break;
kornelski commented 4 years ago

The problem is that pngquant is supposed to generate a new file. If it sometimes didn't generate a new file, it'd be super weird. People would complain to me that the tool sometimes "doesn't work".

shinsenter commented 4 years ago

@kornelski It seems that your image compression algorithm needs to be improved to reduce the number of newly created files that are larger than the original files.

How can they create PNG files smaller than files compressed with pngquant? Have you ever thought about that when reading this issue?

zvezdochiot commented 4 years ago

@shinsenter say:

It seems that your image compression algorithm

https://github.com/kornelski/pngquant/blob/7ffdc41525d80461d1f581644fbf9df135140c67/pngquant.c#L57

There is no algorithm in this repository. It is in a completely different place: https://github.com/ImageOptim/libimagequant

shinsenter commented 4 years ago

@kornelski Looks like I got it wrong? I was just wondering about failed compression ratio in the issue.

The libimagequant library was also participated by you, right?

kornelski commented 4 years ago

Yes, libimagequant part of the pngquant project. It does 99% of the work.

vladimirkondratyev commented 3 years ago

Why don't copy original PNG to a "converted" copy if the size of converted image is larger than original? It will not break existing behavior, pngquant will always create a new file. On the other hand, there will be no confusion, when optimized PNG is larger than original one.