Discussion:
Working with .pbm images in 6.6.2
Ted Onley
2010-09-28 11:48:42 UTC
Permalink
We recently upgraded from 6.4.5 to 6.6.2, and have lost the ability to
convert .pbm files to .pdf files.

My convert command is:
convert file1.pbm file2.pbm -compress zip newfile.pdf

The convert command displays the message:
convert: unable to read image data 'file1.pbm' @
error/pnm.c/ReadPNMImage/651.
convert: unable to read image data 'file2.pbm' @
error/pnm.c/ReadPNMImage/651.
convert: missing as image filename 'newfile.pdf' @
error/convert.c/ConvertImageCommand/2970

I get the same error when trying to convert just one of the files to a
different format as well.

It looks like ImageMagick thinks the .pbm file is corrupt, but I can
convert the .pbm files on my 6.4.5 installation file just fine.

Am I missing something new in 6.6.2? Is there a fix/patch that needs to
be applied to 6.6.2?

Ted Onley
Wolfgang Hugemann
2010-10-01 06:57:58 UTC
Permalink
I tried to reproduce this error with IM 6.6.3-0 Q16 running on Windows.
It seems to work just fine on my computer. I just did

convert -size 200x200 -depth 2 xc:white test.pbm
convert test.pbm test.pdf

and it worked just fine. If it does on your computer, too, the flaw must
be somewhere else.

Where did you get the PBM files from? I think I remember that these are
sometimes written by pdfimages if monochrome bitmaps are extracted from
a PDF (?).

Wolfgang Hugemann
Wolfgang Hugemann
2010-10-01 16:34:52 UTC
Permalink
Well, as you have to admit now, this is no IM error, so this is rather
not the right forum to discuss this issue...

I think you have to nail down what's wrong with these images. I have
seen things like these before, i.e. that corrupt images are read by one
program and produce incorrect output in another program. It could be
that some redundant header information is used by one program and
ignored by another one.

Possibly there is a way of getting rid of superfluoes data by just
truncating the file at the right position, using standard software. (I
have done so with PDF files before.)

You probably have to analyse the PBM files by use of a hexeditor. The
PBM format seems to be rather simple and is described on several
websites. Furthermore, there seem to be ready-made analysation tools for it.

You could also have a look at IM's change log
(http://www.imagemagick.org/script/changelog.php) to find out what
change might have affected its behaviour in regard to PBM files. There
ssems to be a change by christy dating from 2007-09-17.

Good luck!
Wolfgang Hugemann
I tried to reproduce this error with IM 6.6.3-0 Q16 running on Windows.
It seems to work just fine on my computer. I just did
convert -size 200x200 -depth 2 xc:white test.pbm
convert test.pbm test.pdf
and it worked just fine. If it does on your computer, too, the flaw must
be somewhere else.
Where did you get the PBM files from? I think I remember that these are
sometimes written by pdfimages if monochrome bitmaps are extracted from
a PDF (?).
Wolfgang Hugemann
_______________________________________________
Magick-users mailing list
http://studio.imagemagick.org/mailman/listinfo/magick-users
I think what I've discovered is that the .pbm files are suspect. We have
old SuSE linux workstations that have a Panasonic color scanner with a
document feeder attached, which we use to scan shipping documents. We
take those scans and produce a PDF of them and store them on a server
for the entire company to have access to.
We are using SANE to manage the scanner, and what we're getting is a
.pbm file for each page of a scan. A 4 page picking document will scan
as 4 .pbm files. We actually get 5 files. The last file is a 33 byte
file, andt I never determined how that was getting created, so my
program skips that last file and does a convert of the valid files to
stitch together a PDF.
I've always seen a warning from the convert command about an unexpected
end of file when reading the .pbm files during the convert, but the PDF
was produced, and was fine. Now, I get a hard error on the convert, and
no PDF gets produced. I even went back to version 6.4.5, and still get
the hard error. I'm suspecting that the scanning workstation is
producing a bad .pbm file. I tried opening one of the .pbm files in
Gimp, and Gimp reports a PNM image message - Error reading file.
PhotoShop does open the file with not problem. You can see at the bottom
of the image (end of the page) that there is some extra data that isn't
from the original page that was scanned. If I save the image to a new
file with PhotoShop, then the convert works fine.
I guess, even though there appears to be an issue with the .pbm files
from the scanning workstations, I'd like to at least have the
functionality I had before. The other issue is that this is running on a
new server. This new installation is on SuSE Enterprise Linux 10 - SP3,
the old was SuSE Enterprise Linux 10 - no service pak, which makes
things that much more difficult to trace.
Sorry for the long rambling. If you have any thoughts as to how I might
troubleshoot this, I greatly appreciate it!
Ted
Anthony Thyssen
2010-10-03 23:33:34 UTC
Permalink
On Fri, 01 Oct 2010 18:34:52 +0200
magick-users-***@imagemagick.org wrote:

| You probably have to analyse the PBM files by use of a hexeditor. The
| PBM format seems to be rather simple and is described on several
| websites. Furthermore, there seem to be ready-made analysation tools for it.
|

The pbm (as well as pgm, ppm, pnm, pam) format is very simple.

If the header is binary, the file is gzipped
Otherwise the header will be plain text letters and numbers.
After the ascii header you then either have binary or ascii numbers.

That is it.

Any superfluous headers will be in the plain text ascii header.
For example programs add '#' comment lines before the final header
arguments, and in many cases that works. Though not all programs
understand this.

For example

P4
# comment
# comment - next line is the proper header arguments
1 1
{binary here}

Just fire up a editor like VIM in binary (-b) mode
and remove the comment headers and all should be well.



Anthony Thyssen ( System Programmer ) <***@griffith.edu.au>
--------------------------------------------------------------------------
What are the facts? Again and again and again -- what are the _facts_?
Shun wishful thinking, ignore divine revelation, forget what 'the stars
foretell', avoid opinion, care not what the neighbors think, never mind
the unguessable 'verdict of history', -- what are the facts, and to how
many decimal places? You pilot always into an unknown future; facts are
your only clue. Get the facts! -- Lazuras Long, (Aka. Robert Heinlein)
--------------------------------------------------------------------------
Anthony's Castle http://www.cit.griffith.edu.au/~anthony/

Loading...