* Jeffrey Ratcliffe <[EMAIL PROTECTED]>, 2008-06-16, 23:58:
A minimal example can be created with the following command:
$ printf 'P6 1 1 255\n\0\0\0' > tmp.ppm

The problem here is distinguishing between a pbm, which cjb2 will
convert, and ppm, which it will not.

Imagemagick identifies them both as

Format: PNM (Portable anymap)
The 'class' attribute can be used to distinguish between those types:

$ identify tmp.pbm; identify tmp.ppm
tmp.pbm PNM 1x1 1x1+0+0 PseudoClass 2c 1-bit 8b
tmp.ppm PNM 1x1 1x1+0+0 DirectClass 8-bit 14b

[...]
Unless you have any better suggestions, I'll file this as an
imagemagick bug, blocking this one.
The attached patch should fix the issue.

--
Jakub Wilk
--- gscan2pdf.orig	2008-06-17 17:15:37.000000000 +0200
+++ gscan2pdf	2008-06-17 17:27:24.000000000 +0200
@@ -2943,6 +2943,7 @@
      my $x = $image->Read($filename);
      warn "$x" if "$x";
      my $depth = $image->Get('depth');
+     my $class = $image->Get('class');
      my $compression;
 
 # c44 can only use pnm and jpg
@@ -2959,8 +2960,8 @@
 # cjb2 can only use pnm and tif
      else {
       $compression = 'cjb2';
-      if ($format !~ /(pnm)|(tif)/) {
-       my (undef, $pnm) = tempfile(DIR => $dir, SUFFIX => '.pnm');
+      if ($format !~ /(pnm)|(tif)/ or $class eq 'DirectClass') {
+       my (undef, $pnm) = tempfile(DIR => $dir, SUFFIX => '.pbm');
        $x = $image->Write(filename => $pnm);
        warn "$x" if "$x";
        $filename = $pnm;

Reply via email to