My favorites | Sign in
Project Home Downloads Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions
Issue 37: Missing images
2 people starred this issue and may be notified of changes. Back to list
Status:  Fixed
Owner:  pts...@gmail.com
Closed:  Mar 2011


 
Reported by william.bader@gmail.com, May 8, 2010
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

pdfsizeopt.pat
13.1 KB   View   Download
Jul 12, 2010
#1 hata.ra...@gmail.com
I have similar problem, but my PDF file is created by XeLaTeX. I tried to use the patch but it doesn't work for me. Problem remains the same.

I attach file where is image and after running the pdfsizeopt.py, the PDF viewer is unable to display this image.

The composition of PDF is very similar to what william.bader described above in this issue.
2.pdf
312 KB   Download
Jul 13, 2010
#2 hata.ra...@gmail.com
I forgot add PDF file after running pdfsizeopt.py. Now I attach it as well.
2.psom.pdf
186 KB   Download
Feb 10, 2011
Project Member #3 pts...@gmail.com
@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
Project Member #4 pts...@gmail.com
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

Powered by Google Project Hosting