dylanroy / pdfsizeopt

Automatically exported from code.google.com/p/pdfsizeopt
0 stars 0 forks source link

AssertionError: sam2p_np failed (status) under windows #9

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
F:\2009\pdfsizeopt\win32>c:\Python25\python.exe pdfsizeopt.py --use-pngout=true
--use-jbig2=true --use-multivalent=true 1-COVER-INDEX.pdf
info: This is pdfsizeopt.py rUNKNOWN.
info: loading PDF from: 1-COVER-INDEX.pdf
info: loaded PDF of 2036175 bytes
info: separated to 7 objs
info: found 0 Type1 fonts loaded
info: found 0 Type1C fonts loaded
info: will optimize image XObject 1; orig width=8800 height=13600
colorspace=/De
viceGray bpc=1 filter=/CCITTFaxDecode dp=1 size=2035366 gs_device=pngmono
info: optimizing 1 images of 2035366 bytes in total
info: writing ImageRenderer (2035390 image bytes) to: pso.conv.pngmono.tmp.ps
info: executing ImageRenderer with Ghostscript: gs -q -dNOPAUSE -dBATCH
-sDEVICE
=pngmono -sOutputFile="pso.conv-%04d.pngmono.tmp.png" -f
pso.conv.pngmono.tmp.ps

F:\2009\pdfsizeopt\win32>D:\basetools\gs\gs8.64\bin\gswin32c.exe
"-ID:\basetools
\gs\gs8.64\lib;D:\basetools\gs\fonts;C:/WINDOWS/fonts" -q -dNOPAUSE -dBATCH
-sDE
VICE=pngmono -sOutputFile="pso.conv-%04d.pngmono.tmp.png" -f
pso.conv.pngmono.tm
p.ps
ImageRenderer: rendering image XObject 1 width=8800 height=13600 bpc=1
colorspac
e=/DeviceGray filter=/CCITTFaxDecode decodeparms=<< /K -1 /Columns 8800
/Rows 13
600 >> device=pngmono
ImageRenderer: all OK
info: loading image from: pso.conv-0001.pngmono.tmp.png
pdfsizeopt.py:2882: DeprecationWarning: struct integer overflow masking is
depre
cated
  computed_crc = struct.pack('>L', zlib.crc32(chunk_type + chunk_data))
info: loaded PNG IDAT of 1801651 bytes
info: executing image optimizer sam2p_np: sam2p -pdf:2 -c zip:1:9 -s
Gray1:Index
ed1:Gray2:Indexed2:Rgb1:Gray4:Indexed4:Rgb2:Gray8:Indexed8:Rgb4:Rgb8:stop
-- pso
.conv-0001.pngmono.tmp.png pso.conv-1.sam2p-np.pdf
This is sam2p v0.47.
Available Loaders: PS PDF JAI PNG JPEG TIFF PNM BMP GIF LBM XPM PCX TGA.
Available Appliers: XWD Meta Empty BMP PNG TIFF6 TIFF6-JAI JPEG-JAI JPEG
PNM GIF
89a+LZW XPM PSL1C PSL23+PDF PSL2+PDF-JAI P-TrOpBb.
sam2p: Notice: PNM: loaded alpha, but no transparent pixels
sam2p: Notice: job: read InputFile: "pso.conv-0001.pngmono.tmp.png"
sam2p: Notice: writeTTT: using template: p02
sam2p: Notice: applyProfile: applied OutputRule #0
sam2p: Notice: job: written OutputFile: "pso.conv-1.sam2p-np.pdf"
Success.
info: sam2p_np failed, status=0x1
Traceback (most recent call last):
  File "pdfsizeopt.py", line 6027, in <module>
    main(sys.argv)
  File "pdfsizeopt.py", line 6016, in main
    pdf.OptimizeImages(use_pngout=use_pngout, use_jbig2=use_jbig2)
  File "pdfsizeopt.py", line 4911, in OptimizeImages
    cmd_name='sam2p_np'))
  File "pdfsizeopt.py", line 4447, in ConvertImage
    assert 0, '%s failed (status)' % cmd_name
AssertionError: sam2p_np failed (status)

I have asked you about sam2p_np before, but I did not understand your
explain, so I attach the pdf here.

Original issue reported on code.google.com by roc...@gmail.com on 28 Oct 2009 at 11:44

Attachments:

GoogleCodeExporter commented 8 years ago
same error under linux

Original comment by roc...@gmail.com on 28 Oct 2009 at 11:45

GoogleCodeExporter commented 8 years ago
I cannot reproduce the problem under Linux with the latest pdfsizeopt.py. Please
download the newest pdfsizeopt.py and try again on Linux. Once we fix the Linux
issue, we can start investigating the Windows issue. Here is what I get on 
Linux:

$ pdfsizeopt.py --use-pngout=false 1-COVER-INDEX.pdf
info: This is pdfsizeopt.py r99.
info: loading PDF from: /mnt/mandel/warez/tmp/1-COVER-INDEX.pdf
info: loaded PDF of 2036175 bytes
info: separated to 7 objs
info: found 0 Type1 fonts loaded
info: found 0 Type1C fonts loaded
info: will optimize image XObject 1; orig width=8800 height=13600
colorspace=/DeviceGray bpc=1 filter=/CCITTFaxDecode dp=1 size=2035366 
gs_device=pngmono
info: optimizing 1 images of 2035366 bytes in total
info: writing ImageRenderer (2035390 image bytes) to: pso.conv.pngmono.tmp.ps
info: executing ImageRenderer with Ghostscript: gs -q -dNOPAUSE -dBATCH
-sDEVICE=pngmono -sOutputFile='pso.conv-%04d.pngmono.tmp.png' -f 
pso.conv.pngmono.tmp.ps
ImageRenderer: rendering image XObject 1 width=8800 height=13600 bpc=1
colorspace=/DeviceGray filter=/CCITTFaxDecode decodeparms=<< /K -1 /Columns 8800
/Rows 13600 >> device=pngmono
ImageRenderer: all OK
info: loading image from: pso.conv-0001.pngmono.tmp.png
info: loaded PNG IDAT of 1801651 bytes
info: executing image optimizer sam2p_np: sam2p -pdf:2 -c zip:1:9 -s
Gray1:Indexed1:Gray2:Indexed2:Rgb1:Gray4:Indexed4:Rgb2:Gray8:Indexed8:Rgb4:Rgb8:
stop
-- pso.conv-0001.pngmono.tmp.png pso.conv-1.sam2p-np.pdf
This is sam2p v0.47.
Available Loaders: PS PDF JAI PNG JPEG TIFF PNM BMP LBM XPM PCX TGA.
Available Appliers: XWD Meta Empty BMP PNG TIFF6 TIFF6-JAI JPEG-JAI JPEG PNM XPM
PSL1C PSL23+PDF PSL2+PDF-JAI P-TrOpBb.
sam2p: Notice: PNM: loaded alpha, but no transparent pixels
sam2p: Notice: job: read InputFile: pso.conv-0001.pngmono.tmp.png
sam2p: Notice: writeTTT: using template: p02
sam2p: Notice: applyProfile: applied OutputRule #0
sam2p: Notice: job: written OutputFile: pso.conv-1.sam2p-np.pdf
Success.
info: loading image from: pso.conv-1.sam2p-np.pdf
info: loading PDF from: pso.conv-1.sam2p-np.pdf
info: loaded PDF of 1713006 bytes
info: separated to 6 objs
info: loaded PNG IDAT of 1712279 bytes
info: executing image optimizer sam2p_pr: sam2p -c zip:15:9 --
pso.conv-0001.pngmono.tmp.png pso.conv-1.sam2p-pr.png
This is sam2p v0.47.
Available Loaders: PS PDF JAI PNG JPEG TIFF PNM BMP LBM XPM PCX TGA.
Available Appliers: XWD Meta Empty BMP PNG TIFF6 TIFF6-JAI JPEG-JAI JPEG PNM XPM
PSL1C PSL23+PDF PSL2+PDF-JAI P-TrOpBb.
sam2p: Notice: PNM: loaded alpha, but no transparent pixels
sam2p: Notice: job: read InputFile: pso.conv-0001.pngmono.tmp.png
sam2p: Notice: applyProfile: applied OutputRule #2
sam2p: Notice: job: written OutputFile: pso.conv-1.sam2p-pr.png
Success.
info: loading image from: pso.conv-1.sam2p-pr.png
info: loaded PNG IDAT of 1867603 bytes
info: executing image optimizer jbig2: jbig2 -p pso.conv-1.sam2p-pr.png 
>pso.conv-1.jbig2
info: optimized image XObject 1 file_name=pso.conv-1.jbig2 size=1120400 (55%)
methods=jbig2:1120400,sam2p_np:1712461,gs:1801894,sam2p_pr:1867846,#orig:2035366
info: saved 914966 bytes (45%) on optimizable images
info: writing Multivalent input PDF: pso.conv.mi.tmp.pdf
info: saving PDF with 6 objs to: pso.conv.mi.tmp.pdf
info: generated 1121143 bytes (55%)
info: executing Multivalent to optimize PDF: java -cp
/home/pts/prg/pdfsizeopt/trunk/Multivalent.jar tool.pdf.Compress 
pso.conv.mi.tmp.pdf
file:/home/pts/prg/pdfsizeopt/trunk/pso.conv.mi.tmp.pdf, 1121143 bytes
PDF 1.4, producer=iTextSharp 4.1.2 (based on iText 2.1.2u), creator=null
additional compression may be possible with:
     -compact
=> new length = 1121066, saved 0%, elapsed time = 0 sec
info: Multivalent generated pso.conv.mi.tmp-o.pdf of 1121090 bytes (100%)
info: compressed xref stream from 24 to 138 bytes (575%)
info: optimized to 1120993 bytes after Multivalent (100%)
info: saving PDF to: 1-COVER-INDEX.psom.pdf
info: generated 1120993 bytes (55%)

Original comment by pts...@gmail.com on 31 Oct 2009 at 9:37

GoogleCodeExporter commented 8 years ago
line 4513, status = os.system(cmd) can not get the real status we want.

os.system(command)
Execute the command (a string) in a subshell. This is implemented by calling the
Standard C function system, and has the same limitations. Changes to os.environ,
sys.stdin, etc. are not reflected in the environment of the executed command.

On Unix, the return value is the exit status of the process encoded in the 
format
specified for wait(). Note that POSIX does not specify the meaning of the return
value of the C system function, so the return value of the Python function is
system-dependent.

On Windows, the return value is that returned by the system shell after running
command, given by the Windows environment variable COMSPEC: on command.com 
systems
(Windows 95, 98 and ME) this is always 0; on cmd.exe systems (Windows NT, 2000 
and
XP) this is the exit status of the command run; on systems using a non-native 
shell,
consult your shell documentation.

Original comment by roc...@gmail.com on 31 Oct 2009 at 4:49

GoogleCodeExporter commented 8 years ago
after fix the bug, it works fine, but get the wrong PDF
F:\2009\pdfsizeopt\win32>python pdfsizeopt.py --use-pngout=false 1-COVER-INDEX.p
df
info: This is pdfsizeopt.py rUNKNOWN.
info: loading PDF from: 1-COVER-INDEX.pdf
info: loaded PDF of 2036175 bytes
info: separated to 7 objs
info: found 0 Type1 fonts loaded
info: found 0 Type1C fonts loaded
info: will optimize image XObject 1; orig width=8800 height=13600 colorspace=/De
viceGray bpc=1 filter=/CCITTFaxDecode dp=1 size=2035366 gs_device=pngmono
info: optimizing 1 images of 2035366 bytes in total
info: writing ImageRenderer (2035390 image bytes) to: pso.conv.pngmono.tmp.ps
info: executing ImageRenderer with Ghostscript: gs -q -dNOPAUSE -dBATCH -sDEVICE
=pngmono -sOutputFile="pso.conv-%04d.pngmono.tmp.png" -f pso.conv.pngmono.tmp.ps

F:\2009\pdfsizeopt\win32>D:\basetools\gs\gs8.64\bin\gswin32c.exe "-ID:\basetools
\gs\gs8.64\lib;D:\basetools\gs\fonts;C:/WINDOWS/fonts" -q -dNOPAUSE -dBATCH -sDE
VICE=pngmono -sOutputFile="pso.conv-%04d.pngmono.tmp.png" -f pso.conv.pngmono.tm
p.ps
ImageRenderer: rendering image XObject 1 width=8800 height=13600 bpc=1 colorspac
e=/DeviceGray filter=/CCITTFaxDecode decodeparms=<< /K -1 /Columns 8800 /Rows 13
600 >> device=pngmono
ImageRenderer: all OK
info: loading image from: pso.conv-0001.pngmono.tmp.png
info: loaded PNG IDAT of 1801651 bytes
info: executing image optimizer sam2p_np: sam2p -pdf:2 -c zip:1:9 -s Gray1:Index
ed1:Gray2:Indexed2:Rgb1:Gray4:Indexed4:Rgb2:Gray8:Indexed8:Rgb4:Rgb8:stop -- pso
.conv-0001.pngmono.tmp.png pso.conv-1.sam2p-np.pdf
This is sam2p v0.47.
Available Loaders: PS PDF JAI PNG JPEG TIFF PNM BMP GIF LBM XPM PCX TGA.
Available Appliers: XWD Meta Empty BMP PNG TIFF6 TIFF6-JAI JPEG-JAI JPEG PNM GIF
89a+LZW XPM PSL1C PSL23+PDF PSL2+PDF-JAI P-TrOpBb.
sam2p: Notice: PNM: loaded alpha, but no transparent pixels
sam2p: Notice: job: read InputFile: "pso.conv-0001.pngmono.tmp.png"
sam2p: Notice: writeTTT: using template: p02
sam2p: Notice: applyProfile: applied OutputRule #0
sam2p: Notice: job: written OutputFile: "pso.conv-1.sam2p-np.pdf"
Success.
info: loading image from: pso.conv-1.sam2p-np.pdf
info: loading PDF from: pso.conv-1.sam2p-np.pdf
info: loaded PDF of 1713006 bytes
info: separated to 6 objs
info: loaded PNG IDAT of 1712279 bytes
info: executing image optimizer sam2p_pr: sam2p -c zip:15:9 -- pso.conv-0001.png
mono.tmp.png pso.conv-1.sam2p-pr.png
This is sam2p v0.47.
Available Loaders: PS PDF JAI PNG JPEG TIFF PNM BMP GIF LBM XPM PCX TGA.
Available Appliers: XWD Meta Empty BMP PNG TIFF6 TIFF6-JAI JPEG-JAI JPEG PNM GIF
89a+LZW XPM PSL1C PSL23+PDF PSL2+PDF-JAI P-TrOpBb.
sam2p: Notice: PNM: loaded alpha, but no transparent pixels
sam2p: Notice: job: read InputFile: "pso.conv-0001.pngmono.tmp.png"
sam2p: Notice: applyProfile: applied OutputRule #2
sam2p: Notice: job: written OutputFile: "pso.conv-1.sam2p-pr.png"
Success.
info: loading image from: pso.conv-1.sam2p-pr.png
info: loaded PNG IDAT of 1867603 bytes
info: executing image optimizer jbig2: jbig2 -p pso.conv-1.sam2p-pr.png >pso.con
v-1.jbig2
Error in findFileFormat: failed to read first 8 bytes of file
info: optimized image XObject 1 file_name=pso.conv-1.jbig2 size=412 (0%) methods
=jbig2:412,sam2p_np:1712461,gs:1801894,sam2p_pr:1867846,#orig:2035366
info: saved 2034954 bytes (100%) on optimizable images
info: writing Multivalent input PDF: pso.conv.mi.tmp.pdf
info: saving PDF with 6 objs to: pso.conv.mi.tmp.pdf
info: generated 1151 bytes (0%)
info: executing Multivalent to optimize PDF: java -cp Multivalent.jar tool.pdf.C
ompress pso.conv.mi.tmp.pdf
file:/F:/2009/pdfsizeopt/win32/pso.conv.mi.tmp.pdf, 1151 bytes
PDF 1.4, producer=iTextSharp 4.1.2 (based on iText 2.1.2u), creator=null
additional compression may be possible with:
         -compact
=> new length = 1068, saved 7%, elapsed time = 0 sec
info: Multivalent generated pso.conv.mi.tmp-o.pdf of 1088 bytes (95%)
info: compressed xref stream from 16 to 130 bytes (813%)
info: optimized to 993 bytes after Multivalent (91%)
info: saving PDF to: 1-COVER-INDEX.psom.pdf
info: generated 993 bytes (0%)

Original comment by roc...@gmail.com on 31 Oct 2009 at 5:09

Attachments:

GoogleCodeExporter commented 8 years ago
As I said before, please run it on Linux, and please report what you get, and 
if they
are correct.

Original comment by pts...@gmail.com on 31 Oct 2009 at 7:40