Increasing file size for pngquant output when using PIL

If I compress and draw using pngquant and then read and write using PIL, I see that the file size increases significantly (sometimes up to 2x). Does anyone have any clues? I suspect this may be due to some PIL flags, but are not familiar enough with it.

+4
source share
2 answers

and then read and write using PIL, I see that the file size increases significantly (sometimes up to 2x)

Since PNG is lossless and therefore does not introduce artifacts that can be problematic for other encoders, I see only three real possibilities:

  • (, 8 , 24 )
  • -
  • ( , , , 2x - , 1.2x, )

, PIL , pngquant. PNG, (PLTE, tEXT ..) , ( google).

zLib (, , advpng zlib ), , , .

+3

- RGBA , PNG , .

pngquant PIL:

$ wget https://pngquant.org/Ducati_side_shadow-fs8.png
$ python
>>> from PIL import Image
>>> im = Image.open("Ducati_side_shadow-fs8.png")
>>> im.rotate(180).save("output.png")
$ stat -c "%s %n" *.png
23405 Ducati_side_shadow-fs8.png
23362 output.png

output.png 43 . , .

0

Source: https://habr.com/ru/post/1673358/


All Articles