The size of png images will increase after being merged into pdf #4449
-
I browsed through the official documentation. No matter how a png image is inserted, it will cause the pdf file to become larger, but a jpg file will not. The size of the pdf file obtained in jpg format is approximately the same as the original image size. Both formats use the same compression parameters when saving files |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 3 replies
-
Provide reproducing data please. Which options did you use on save? |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
This is my code. When replying, I don't know why there was a problem with the line break |
Beta Was this translation helpful? Give feedback.
-
The jpg files are basically the same, but the png files are all about 50% higher |
Beta Was this translation helpful? Give feedback.
-
In fact, this png was originally larger. I processed it with PIL. Could it be that the image was restored due to re-decompression during the pymupdf merge process |
Beta Was this translation helpful? Give feedback.
Image insertion effectively happens under the control of the base library. Currently, we cannot influence the compression parameters used here.
So it may be that some PNGs indeed increase under the insertion's re-compression.
This is especially true when PNGs contain an alpha channel (transparency), which cannot happen with JPEGs.