-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pnmtopng: fatal libpng error: Extra compressed data; adding imgdataopt #51
Comments
Hi.
On Wed, Oct 4, 2017 at 4:36 AM, Péter Szabó ***@***.***> wrote:
The image stream in bad_image_extra_data.pdf indeed contains extra bytes
after the image data. The expected behavior would be truncating those extra
bytes. What happens instead is pdfsizeopt calls sam2p, which calls pnmtopng,
which fails with fatal error pnmtopng: fatal libpng error: Extra compressed
data, making sam2p fail, making pdfsizeopt fail.
I don't get this with my system here. I'm using an old version of
sam2p, 0.49.2-3+b1 (that's been patched by Debian---I still have not
had the time to package a new version to reintroduce it into the
archives), and pnmtopng from netpb version 2:10.0-15.3+b2.
I can send you the compressed file that I get, if you want to check it.
Thanks,
…--
Rogério Brito : rbrito@{ime.usp.br,gmail.com} : GPG key 4096R/BCFCAAAA
http://cynic.cc/blog/ : github.com/rbrito : profiles.google.com/rbrito
DebianQA: http://qa.debian.org/developer.php?login=rbrito%40ime.usp.br
|
Yes, please attach the temporary .png files pdfsizeopt has created here, and please copy the console output of pdfsizeopt. sam2p shouldn't make a difference. pngtopnm may be different. |
A radical approach to fix these two bugs (#51 and #52) is replacing sam2p as a dependency of pdfsizeopt by a newly written tool named imgdataopt, which will provide a very small subset of the functionality of sam2p used by pdfsizeopt:
Non-features:
|
Hi, Péter.
On Oct 04 2017, Péter Szabó wrote:
Yes, please attach the temporary .png files pdfsizeopt has created here,
and please copy the output of pdfsizeopt. sam2p shouldn't make a
difference. pngtopnm may be different.
I didn't know where you wanted me to break the execution. I broke it as
shown in the following trace:
```
$ ~/Downloads/pdfsizeopt/pdfsizeopt --use-pngout=no --use-multivalent=no bad_image_extra_data.pdf
info: This is pdfsizeopt rUNKNOWN size=378567.
info: prepending to PATH: /home/rbrito/Downloads/pdfsizeopt
info: loading PDF from: bad_image_extra_data.pdf
info: loaded PDF of 24810 bytes
info: separated to 5 objs + xref + trailer
info: parsed 5 objs
info: found 0 Type1 fonts loaded
info: found 0 Type1C fonts loaded
info: will optimize image XObject 4; orig width=681 height=250 colorspace=/DeviceRGB bpc=8 inv=False filter=/FlateDecode dp=1 size=24286 gs_device=png16m
info: saving PNG to psotmp.13626.img-4.parse.png
info: written 24130 bytes to PNG
info: optimizing 1 images of 24286 bytes in total
Traceback (most recent call last):
File "/home/rbrito/Downloads/pdfsizeopt/pdfsizeopt", line 41, in <module>
sys.exit(main.main(sys.argv, script_dir=script_dir))
File "/home/rbrito/Downloads/pdfsizeopt/lib/pdfsizeopt/main.py", line 9100, in main
pdf.OptimizeImages(img_cmd_patterns=img_cmd_patterns)
File "/home/rbrito/Downloads/pdfsizeopt/lib/pdfsizeopt/main.py", line 7084, in OptimizeImages
assert False
AssertionError
$ ls -l
total 52
-rw-r--r-- 1 rbrito rbrito 24810 Oct 5 23:29 bad_image_extra_data.pdf
-rw-r--r-- 1 rbrito rbrito 24130 Oct 5 23:29 psotmp.13626.img-4.parse.png
$
The PNG that was generated is attached to this message (I hope that github
doesn't eat it on the way---if it does, I will attach it via the regular web
interface).
Hope this helps,
Rogério.
…--
Rogério Brito : rbrito@{ime.usp.br,gmail.com} : GPG key 4096R/BCFCAAAA
http://cynic.cc/blog/ : github.com/rbrito : profiles.google.com/rbrito
DebianQA: http://qa.debian.org/developer.php?login=rbrito%40ime.usp.br
|
I just commented out all the calls to
I will attach the contents of the directory as a tarball. |
Here they go. |
Is |
The file with |
Yes, Thank you for the uploads! |
Indeed, using imgdataopt instead of sam2p fixes the problem, because imgdataopt ignores extra data after the image data. (It also ignores the Adler-32 checksum.) The change has been rolled out for Linux, Win32 and macOS program binaries (i.e. sam2p was change to imgdataopt, without renaming it), and to instructions in README.md for compiling from source. Thus this issue is fixed. |
The image stream in bad_image_extra_data.pdf indeed contains extra bytes after the image data. The expected behavior would be truncating those extra bytes. What happens instead is pdfsizeopt calls sam2p, which calls pnmtopng, which fails with fatal error
pnmtopng: fatal libpng error: Extra compressed data
, making sam2p fail, making pdfsizeopt fail.Image viewer qiv also indicates the error
Extra compressed data
on the corresponding PNG, but it at least shows the image.The text was updated successfully, but these errors were encountered: