Closed rbrito closed 6 years ago
pdfsizeopt (both with sam2p and pngout) is already optimizing the palette, and inserts the smaller of the grayscale and the indexed image. If it's not happening to some PDFs, then this is a bug in pdfsizeopt. Please copy-paste the console output of pdfsizeopt and attach the offending input PDF as usual to this issue.
it would be great to be able to remove the need of passing the options
-c0
topngout
or-np -nc
tooptipng
This cannot be done in the general case, because the PDF specification requires that the target image object of an /SMask
must be /ColorSpace /DeviceGray
. pdfsizeopt contains code to comply to this requirement (search for force_grayscale_obj_nums
in main.py
), and passing these options to image optimizers, and ignoring non-grayscale output of those image optimizers is part of this.
If you have an example PDF in which pdfsizeopt emits a grayscale image, which is not required to be grayscale, and a non-grayscale version would be smaller, please attach it to this issue. I'll then reopen this issue.
Dear, @pts.
Reading the code for pdfsizeopt, I saw that if one external compressor was able to optimize the palette of bitmapped grayscale images in a way that makes it use a smaller amount of colors, the result of that (possibly expensive, but desired) operation is discarded.
Would it be possible to add to pdfsizeopt?
In particular, it would be great to be able to remove the need of passing the options
-c0
topngout
or-np -nc
tooptipng
(or similar options given to other compressors).Thanks,
Rogério.