Posted February 22, 2015
rtcvb32: 4) No no no...I've used AdvanceComp's advpng, and it usually does a really bad job... advdef usually does better, and i can lump .gz files in with it too if i have to. Had something to do with it's more optimized if you wanted to save screenshots or other things for AdvanceMame i think...
Hmm. I'll have to put a statistical comparison between advpng and advdef on my TODO list then. rtcvb32: Hmmm so the + would deal with the odd 'bad file number' error when you try to send it a few hundred images? Interesting... I know i made a script i still use that separates out zips or png's to run 4 at a time (to match my cores) which gives me better performance overall, and they all finish about the same time... Had to re-write it form bash to awk to make it fast though...
In that case, use this instead find . -iname "*.png" -print0 | parallel -0X advdef -z4 {}
Here's how it works:
1. GNU parallel takes a list of files or commands and performs some action on them in parallel. (In this case, feeding them to "advdef -z4")
2. -print0 causes find to output a list of files separated by binary NUL characters (one of only two characters not allowed in filenames on POSIX-compliant filesystems, the other being the / path separator.)
3. The -0 flag tells GNU parallel to expect a NUL-separated list rather than a newline-separated list.
4. The -X flag to GNU parallel is equivalent to --exec + with find. It tells it to feed multiple files to the same command up to the command-line length limit.
5. If you don't specify a -j option to GNU parallel, it checks how many CPU cores you have and runs one subprocess for each.
If it's going to take a long time, you may also want to consider using -0 --eta instead of -0X so GNU parallel will display a progress readout and estimated time to completion.
The GNU parallel manual page has examples as well as comparisons to other similar tools, if you find that you don't have access to GNU parallel for some reason.
ssokolow: Also, check out gifsicle -O3 for optimizing Animated GIFs, for losslessly optimizing JPEG files, and [url=https://github.com/svg/svgo]svgo for optimizing SVG files.
rtcvb32: Definitely interested, although i tried to find utilities like these before but had trouble, too much crap clogging google's search engine to help me find them... Yes, it does rule out closed-source code, but that's a perfectly decent trade-off to make and really cuts the crap, given that people who produce crap would never be willing to open-source their precious "first on earth" solution for the community to "plunder", "steal", or "ruin". (And the various Linux distros' package repositories wouldn't take it if you paid them.)
Post edited February 22, 2015 by ssokolow