Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PNGoo - command-line version (cli/cmd) #354

Open
ttodua opened this issue Mar 10, 2020 · 9 comments
Open

PNGoo - command-line version (cli/cmd) #354

ttodua opened this issue Mar 10, 2020 · 9 comments

Comments

@ttodua
Copy link

ttodua commented Mar 10, 2020

Hi.
I don't know what i am missing, but tried many times with different (transarent) images, and the results I am getting from PNGoo, i cant get with any command line arguments with pngquant. If original file is 300kb, pngquant produces around 150kb, while PNGoo around 50kb.

So, i've switched to use PNGoo from command line. at this moment, i've created Console Application ( dependent project onto PNGoo, which is closed and cant commit there), so, when I drag&drop file, or execute like pngoo-cmd image.png.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using PNGoo;

namespace pngoo_command_line
{
    class Program
    {
        static void Main(string[] args)
        {
            var fileList_ = new List<string>(); 
             
            for (int i = 0; i < args.Length; i++)
            {
                fileList_.Add(args[i]);
            }
            if (fileList_.Count>0)
            {
                string[] fileList = fileList_.ToArray();
                processAll(fileList);
            }
        }

        private static CompressionSettings compressionSettings = new CompressionSettings();

        static void processAll(string[] fileList)
        {
            // let's start the batch
            PNGoo.BatchOperations.BatchFileCompressor batch = new PNGoo.BatchOperations.BatchFileCompressor();
            batch.OutputDirectory = null;
            batch.OutputIfLarger = false;
            batch.CompressionSettings = compressionSettings;
            batch.FilePaths = fileList;
            batch.Start();
        }
    }
}

so, what I ask, can you please add an ability to run PNGoo from command line too? so, the main PNGoo exe could determine if it is run from command-line, it should output form, instead work under cmd.

or otherwise, give us some insights how to run pngquant samely from cmd to get same results as PNGoo.

@ttodua ttodua changed the title adding command-line to pngoo PNGoo - command-line version (cli/cmd) Mar 10, 2020
@kornelski
Copy link
Owner

All pngoo does is launch pngquant command line. It does nothing else.

@ttodua
Copy link
Author

ttodua commented Mar 11, 2020

All pngoo does is launch pngquant command line. It does nothing else.

Then how to explain, that when I compressing this file with with PNGoo, i get 5kb output file, but with same settings if i launch pngquant, it produces 20kb output file. Can you advise how to execute pngquant (with what parameters) to get the same result for that file?
thanks in advance

@kornelski
Copy link
Owner

Try setting the same number of colors or quality as the GUI.

Are you calling the same exe as pngoo, or a different version?

It really is just a launcher for pngquant exe:

https://github.com/kornelski/pngoo/blob/f2c614d5cb666ed0eec288138bdd645cfed41e6e/src/PNGoo/Compressor/PNGQuant.cs#L23-L46

@ttodua
Copy link
Author

ttodua commented Mar 11, 2020


@ttodua
Copy link
Author

ttodua commented Mar 11, 2020

that's why I am surprised too.
and that's why I've linked the example PNG file, and you can see yourself that it will produce unexpected results.
I mean, with PNGoo it is produced much less file, while (with same settings) with pngquant it is larger (i've given the exact kilobytes in above post).
that's why I needed if you could check what happens (a bug or issue) in any of your app? (either PNGoo or pngquant).


UPDATE:
what I observed recently, is that before PNGoo sends to data to pngquant, it has (already by that moment) reduced file size compared to original file size (i've checked the file-size of the "tmp" file that PNGoo creates, and it's really less than original file. and that tmp file data is sent to pngquant as I see)

so, obviously, PNGoo is not just launched of pngquant, instead it does some more file optimization/reduction before sending to pngquant too.

you can try yourself with my above linked .png file and see that is the case.

Would be nice if you integrate that optimization in pngquant too, so we could disregard PNGoo in command-line, and directly use pngquant.

@ttodua
Copy link
Author

ttodua commented Mar 18, 2020

Did you have a chance (really 1 minute) to confirm that behavior on the above provided sample image? maybe it's related to the bytes of transparency being ignored in PNGoo, and not in PNGquant?

@kornelski
Copy link
Owner

pngquant is incapable of preserving RGB values of transparent bytes due to the colorspace it uses internally. It couldn't have that bug even if it wanted to :)

Can you provide the tmp file, the direct pngquant, and pnggoo files to compare?

@ttodua
Copy link
Author

ttodua commented Mar 19, 2020

I have deleted previous messages, and now, briefly, here I am sending a real proof of the misbehavior (which is caused by something I was unable to find, other than that PNGoo does something else).

Here I am attaching several image samples - https://we.tl/t-vsC2aWMItO

in each sample folder, there are 4 images:
A) the original png
B) with "pngquanti_new" suffix (compressed with pngquant.exe, latest version from website)
C) with "pngquanti_old" suffix (compressed with old pngquanti.exe from , latest version from PNGoo's /lib/pngquant/pnqguanti.exe. it does produces same result as that pngoo.exe)
D) with "pngoo_new" suffix (compressed with PNGoo.exe, BUT WITH PNGoo/lib/pngquant/pnqguanti.exe replaced actually by latest available pngquant.exe )

so, you see the differences yourself. not only they have different results, but even (B) and (D) have different results (even though the same pngquant exe is used in those occasions)

@ttodua
Copy link
Author

ttodua commented Jul 13, 2020

well, it's a pitty author ignored this topic. Unfortunately, the above "wetransfer" files has been deleted and I don't have time to generate them again.

just for historical purposes if anyone ever will take a minute to check and confirm themselves, i will attach the original file here - https://drive.google.com/file/d/1yzevMqZz-0fDaJ5nipVw4wrnPeRu36X8/view?usp=sharing

i have already mentioned the steps (only 1 minute needed) to reproduce the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants