| Issue 37: | Missing images | |
| 2 people starred this issue and may be notified of changes. | Back to list |
Images sometimes do not show in the pdfsizeopt output.
I have an example file (that I unfortunately can not post) that was made by
OpenOffice.org 3.1. The image in the original has a soft mask, and the
mask is solid black and has an inverted /Decode entry of [ 1 0 ].
pdfsizeopt drops the /Decode entry, which changes the mask from passing
every pixel of the image to dropping every pixel of the image, and the PDF
ends up with a white hole where the image should be. The patch below keeps
UpdatePdfObj() from clearing the /Decode entry.
William
williambader@hotmail.com
--- pdfsizeopt/pdfsizeopt.py- 2010-03-24 21:06:15.000000000 +0000
+++ pdfsizeopt/pdfsizeopt.py 2010-05-09 03:52:06.000000000 +0100
@@ -2592,15 +2592,17 @@
else:
pdf_obj.Set('BitsPerComponent', pdf_image_data['BitsPerComponent'])
pdf_obj.Set('ColorSpace', pdf_image_data['ColorSpace'])
- pdf_obj.Set('Decode', pdf_image_data.get('Decode'))
+ if pdf_obj.Get('Decode') == None:
+ # Update Decode only if it is currently not set
+ pdf_obj.Set('Decode', pdf_image_data.get('Decode'))
pdf_obj.Set('Filter', pdf_image_data['Filter'])
pdf_obj.Set('DecodeParms', pdf_image_data.get('DecodeParms'))
pdf_obj.Set('Length', len(pdf_image_data['.stream']))
- # Don't pdf_obj.Set('Decode', ...): it is goot as is.
+ # Don't pdf_obj.Set('Decode', ...): it is good as is.
pdf_obj.stream = pdf_image_data['.stream']
def CompressToZipPng(self):
- """Compress self.idat to self.compresson = 'zip-png'."""
+ """Compress self.idat to self.compression = 'zip-png'."""
assert self
if self.compression == 'zip-png':
# For testing: ./pdfsizeopt.py --use-jbig2=false --use-pngout=false
pts2ep.pdf
PDF objects for the image in the original file:
13 0 obj
<</Type/XObject/Subtype/Image/Width 1011 /Height 626 /BitsPerComponent 8
/Length 14 0 R
/Filter/FlateDecode/ColorSpace/DeviceRGB
/SMask 15 0 R
>>
stream
endstream
endobj
14 0 obj
24398
endobj
15 0 obj
<</Type/XObject/Subtype/Image/Width 1011 /Height 626 /BitsPerComponent 8
/Length 16 0 R
/Filter/FlateDecode/ColorSpace/DeviceGray
/Decode [ 1 0 ]
>>
PDF objects for the image in the unpatched pdfsizeopt output:
49 0 obj
<</BitsPerComponent 8/ColorSpace/DeviceRGB/Filter/FlateDecode/Height
626/Length 20524/SMask 50 0 R/Subtype/Image/Type/XObject/Width 1011>>stream
endstream endobj
50 0 obj
<</BitsPerComponent 1/ColorSpace/DeviceGray/Filter/FlateDecode/Height
626/Length 100/Subtype/Image/Type/XObject/Width 1011>>stream
endstream endobj
Jul 13, 2010
I forgot add PDF file after running pdfsizeopt.py. Now I attach it as well.
Feb 10, 2011
@hata.radim: Your problem has been fixed in r150 (it converts 2.pdf correctly). If the fix doesn't work for you, please create a new issue for that.
Status:
Accepted
Mar 4, 2011
Closing this issue now. Feel free to reopen it if you have an example PDF with an image pdfsizeopt doesn't optimize properly.
Status:
Fixed
|
312 KB Download