mahnunchik / gulp-responsive

gulp-responsive generates images at different sizes
https://npmjs.com/gulp-responsive
MIT License
502 stars 62 forks source link

support for different types of png (png-8, png-24) in order to optimize file size #15

Open pniederlag opened 9 years ago

pniederlag commented 9 years ago

I have an 826x517 pixel input png. It has a filesize of 9kb (9008 bytes)

Using gulp-resize with width: 200 on the image gives me a resulting file with 17kb (16939 bytes) size.

Is this just a matter of settings(compressionLevel, ...) or is this an expected behaviour?

pniederlag commented 9 years ago

png has different formats or say ways to store pixels. This is also sometimes refererd to as png-8 or png-24 (as gimp calls it). Some more details can be found on Wikipedia http://en.wikipedia.org/wiki/Portable_Network_Graphics#Pixel_format

As the image to which I am referring is a transparent black and white image the question would be wether is possible to force and indexed color palette (as used in the input png) in the resulting image via gulp-responsive and/or sharp.

mahnunchik commented 9 years ago

Hi @lovell

Could you please help me with this issue?

lovell commented 9 years ago

Hello, libvips supports reading of PNG images with 1, 2, 4, 8 and 16 bits per channel and writing of PNG images with 8 and 16 bits per channel.

1, 2 and 4-bit input PNG images with their own palette are converted to RGB before further processing. Support for downsampling (quantise+dither) from 8 bit to 1, 2 or 4 bit would be an enhancement to libvips.

For now, the withoutAdaptiveFiltering method can help reduce the size of output PNG images, especially if they originate from 1, 2, or 4 bit input PNG images.

mahnunchik commented 9 years ago

@lovell Thanks you!

BroFox86 commented 6 years ago

It seems gulp-responsive doesn't work correctly with png-8. I've created 2nd pass task for png images with imagemin-pngquant.