| Issue 49: | jbig2enc for Mac OS X | |
| 1 person starred this issue and may be notified of changes. | Back to list |
The only why to compile jbig2enc is through a homebrew formula from Misty De Meo but it seems pdfoptsize isn't compatible to that binary because jbig2 isn't executed. When running jbig2 as single command it's working properly, I also tested it with pdfbeads (http://rubygems.org/gems/pdfbeads). http://www.diybookscanner.org/forum/viewtopic.php?f=3&t=683&p=10895#p10895 https://raw.github.com/mistydemeo/homebrew/55e72cf6b673d82838ea233022daecd77f738c99/Library/Formula/jbig2enc.rb Here is the output from pdfsizeopt: python pdfsizeopt.py --use-pngout=true --use-jbig2=true --use-multivalent=true Scan-110805-0023_1L.pdf info: This is pdfsizeopt.py rUNKNOWN size=279220. info: loading PDF from: Scan-110805-0023_1L.pdf info: loaded PDF of 178418 bytes info: separated to 17 objs + xref + trailer warning: cannot parse obj 13: __main__.PdfTokenParseError: endobj/stream not found from ofs=177711 to ofs=177727 warning: cannot parse obj 13: __main__.PdfTokenParseError: endobj/stream not found from ofs=177711 to ofs=177727 info: found 0 Type1 fonts loaded info: found 0 Type1C fonts loaded info: will optimize image XObject 8; orig width=2273 height=3308 colorspace=/DeviceGray bpc=8 filter=[ /LZWDecode ] dp=0 size=171101 gs_device=pnggray info: optimizing 1 images of 171101 bytes in total info: writing ImageRenderer (171103 image bytes) to: pso.conv.pnggray.tmp.ps info: executing ImageRenderer with Ghostscript: gs -q -dNOPAUSE -dBATCH -sDEVICE=pnggray -sOutputFile='pso.conv-%04d.pnggray.tmp.png' -f pso.conv.pnggray.tmp.ps ImageRenderer: rendering image XObject 8 width=2273 height=3308 bpc=8 colorspace=/DeviceGray filter=[/LZWDecode] decodeparms=null device=pnggray ImageRenderer: all OK info: loading image from: pso.conv-0001.pnggray.tmp.png info: loaded PNG IDAT of 148478 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.pnggray.tmp.png pso.conv-8.sam2p-np.pdf This is sam2p 0.49. 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 GIF89a+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.pnggray.tmp.png sam2p: Notice: writeTTT: using template: p02 sam2p: Notice: applyProfile: applied OutputRule #0 sam2p: Notice: job: written OutputFile: pso.conv-8.sam2p-np.pdf Success. info: loading image from: pso.conv-8.sam2p-np.pdf info: loading PDF from: pso.conv-8.sam2p-np.pdf info: loaded PDF of 108539 bytes info: separated to 5 objs + xref + trailer info: loaded PNG IDAT of 107818 bytes info: executing image optimizer sam2p_pr: sam2p -c zip:15:9 -- pso.conv-0001.pnggray.tmp.png pso.conv-8.sam2p-pr.png This is sam2p 0.49. 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 GIF89a+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.pnggray.tmp.png sam2p: Notice: applyProfile: applied OutputRule #2 sam2p: Notice: job: written OutputFile: pso.conv-8.sam2p-pr.png Success. info: loading image from: pso.conv-8.sam2p-pr.png info: loaded PNG IDAT of 107922 bytes info: executing image optimizer jbig2: jbig2 -p pso.conv-8.sam2p-pr.png >pso.conv-8.jbig2 Error in pixReadStreamPng: function not present Error in pixReadStream: png: no pix returned Error in pixRead: pix not read info: jbig2 failed, status=0x300 Traceback (most recent call last): File "pdfsizeopt.py", line 6968, in <module> main(sys.argv) File "pdfsizeopt.py", line 6951, in main pdf.OptimizeImages(use_pngout=use_pngout, use_jbig2=use_jbig2) File "pdfsizeopt.py", line 5719, in OptimizeImages cmd_name='jbig2', do_just_read=True)[1] File "pdfsizeopt.py", line 5162, in ConvertImage assert 0, '%s failed (status)' % cmd_name AssertionError: jbig2 failed (status)
Aug 8, 2011
Thank you for your support. Here's the binary.
Aug 26, 2011
FYI See the expected output of jbig2 -p pso.conv-8.sam2p-pr.png >pso.conv-8.jbig2 attached.
Aug 27, 2011
Thank you for taking time to report this issue and attach all relevant files. Based on the information you have shared, I was able to provide a fix. The most probable reason of the failure of your jbig2 binary is that it uses a leptonica library without png support compiled in. If you recompiled leptonica with png support (possibly compiling libpng as well), the errors Error in pixReadStreamPng: function not present Error in pixReadStream: png: no pix returned Error in pixRead: pix not read would go away. However, this work is not necessary, because I compiled it for you (and for other pdfsizeopt users), just download http://pdfsizeopt.googlecode.com/files/jbig2.darwin , rename it to jbig2, chmod +x it, and move it next to pdfsizeopt.py. Please report whether it's successful. For me it succeeds with the command jbig2 -p pso.conv-8.sam2p-pr.png >pso.conv-8.jbig2 , and it produces the expected output file. FYI See the build.sh in https://code.google.com/p/pts-mini-gpl/source/browse/#svn/trunk/build-jbig2 how I compiled the jbig2 tool for Mac OS X 10.5. I basically downloaded the vanilla * zlib-1.2.5.tar.gz * libpng-1.2.46.tar.gz * leptonica-1.68.tar.gz * agl-jbig2enc-0.27-20-ge8be922.tar.gz and compiled and installed them with the gcc-mp-4.4 in MacPorts. |
105 KB View Download