A short summary of the problems I was having and how they were solved.
- PNMPlus tools (specifically pnmtopnm -plain) do not work well with convert's output stream
Skip the use of pnmtopnm and instead use the -compress none option when converting to a PBM image.
- convert sends PNM output to STDOUT in a stream rather than "chunking" it.
That is by design. http://www.imagemagick.org/Usage/files/#adjoin
It is the responsibility of the script/program ingesting the output from convert to buffer the input stream until a complete image has been obtained.A major problem with saving images, is that ImageMagick works with a ordered sequence (list) of images, not just one image at a time. Because of this IM will attempt to write ALL the images in the current image sequence into the filename given.
------------------------
I am using the Windows precompiled binaryImageMagick-6.8.8-0-Q16-x64-dll.exe on Windows 7 Professional x86.
Code: Select all
>convert -version
Version: ImageMagick 6.8.8-0 Q16 x64 2013-12-21 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC
Features: DPC Modules OpenMP
Delegates: bzlib cairo freetype jbig jng jp2 jpeg lcms lqr pangocairo png ps rsvg tiff webp xml zlib
Here is my pipeline:
Code: Select all
convert pdf:2a_e9c_540.pdf -crop 10x10+150+150 +repage pbm:- | pnmtopnm -plain | BITS-N-BOBS.py
Here is an example of the output from convert:
(converted to a plain P1 PBM stream for posting purposes; the actual output from convert is a binary P4 stream)
Code: Select all
P1
10 10
0000000000
0110000110
0110000110
0110000110
0110000110
0110000110
0110000110
0111111110
0111111110
0000000000P1
10 10
0000000000
0000110000
0000110000
0000110000
0111111110
0111111110
0000110000
0000110000
0000110000
0000000000P1
10 10
0000000000
0111111110
0111111110
0110000110
0110000110
0110000110
0110000110
0111111110
0111111110
0000000000