I am trying to get the best setup possible for compressing pngs.
I have found there are some plugins available here for imagemin: https://www.npmjs.com/browse/keyword/imageminplugin
I have tried all the PNG options but the compression rates appear to be pretty bad.
- example image original size - 1.4MB
- TinyPNG.com - 413KB
- pngquant - 541KB
- pngout - can't get it to work - see https://github.com/imagemin/imagemin-pngout/issues/2
- pngcrush - 992KB
- optipng (default options) - 906KB
- advpng - 906KB
pngquant appears to have the highest compression rate, (obviously the worst quality) similar quality to tinypng, but could still get nearer the tinypng figure.
Essentially I have 3 questions:
Question 1: Changing the options for both advpng & optipng doesn't seem to alter the filesize, here is an example, am I using this correctly? I am guessing that maybe it isn't using my settings at all and falling back to the default settings? If you notice the filesizes of these two are identical!:
.pipe(imagemin(
imageminOptipng({
optimizationLevel: 4
})
))
Question 2: Am I using "pngout" in correctly? Is there a method to use it that I do not know about? The examples from their page seem not to work & neither does this method:
.pipe(imagemin([
imageminPngout({
strategy: 1
})
]))
Question 3: Is there a better method to deal with png compression that I haven't yet found? Ideally I would somehow like to get a method that has the rate of pngquant, but the quality is a bit better.