pts / pdfsizeopt

PDF file size optimizer
GNU General Public License v2.0
762 stars 66 forks source link

pdfsizeopt crashing with a sam2p error #160

Closed jul059 closed 1 year ago

jul059 commented 1 year ago

windows build from feb 24 2023 crashes on this pdf with a sam2p.exe error. I have encountered other pdfs crashing with the same error.

command is pdfsizeopt --use-image-optimizer=ECT,jbig2

The same command works with the old build.

sample_sam2p_crash.pdf

pts commented 1 year ago

Thank you for reporting this! Please copy-paste the full console output of pdfsizeopt.

pts commented 1 year ago

Indeed, I can reproduce this bug, no need to post the console output. This bug also happens on Linux, the sam2p program in the newest libexec also crashes there:

$ sam2p -j:quiet -pdf:2 -c zip:1:9 -s Gray1:Indexed1:Gray2:Indexed2:Rgb1:Gray4:Indexed4:Rgb2:Gray8:Indexed8:Rgb4:Rgb8:stop -- issue160sub.png issue160sub4.pdf
Segmentation fault (core dumped)

Download this to reproduce: issue160sub.png

pts commented 1 year ago

Fixed in https://github.com/pts/imgdataopt/commit/ccf2b37a2eb4bb009aed06e86a241f4741b628de .

pts commented 1 year ago

New, fixed binaries are available (including the fixed imgdataopt, named as sam2p). Please reinstall pdfsizeopt by following the instructions on https://github.com/pts/pdfsizeopt.

jul059 commented 1 year ago

On my system with v8, pdfsizeopt is still crashing with the pdf in the first post, but sam2p is not throwing the same error.

image

pts commented 1 year ago

Indeed, v8 is still buggy, it also fails for me in img-3126 with the error message fatal: bad palette size. This is a diferent bug though, I have to diagnose and fix it in imgdataopt. Thank you for your patience.

pts commented 1 year ago

Fixed it in https://github.com/pts/imgdataopt/commit/a245e29c04e007d48a6242cdf770f14c690cbce7, and released it in v9.

New, fixed binaries are available (including the fixed imgdataopt, named as sam2p). Please reinstall pdfsizeopt by following the instructions on https://github.com/pts/pdfsizeopt.

I've just checked that now pdfsizeopt completes successfully for your sample_sam2p_crash.pdf. However, it is not able to reduce the file size by much, only around 2%:

info: generated 9266221 bytes (98%)