ImageMagick CCITT Group4 pdf creation doesn't work anymore

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
multixrulz
Posts: 2
Joined: 2016-09-19T03:27:46-07:00
Authentication code: 1151

ImageMagick CCITT Group4 pdf creation doesn't work anymore

Post by multixrulz »

I've been creating highly compressed PDFs from document scans using the following command:

Code: Select all

convert input.png -despeckle -normalize -level 10%,90% -alpha off -monochrome -compress Group4 -quality 100 output.pdf
This has suddenly stopped working -- to be more precise, a small part of the top of the image appears in the PDF, while the rest is white. The part that appears seems to be approximately the same number of bytes of the input file, regardless of the total file size.

I'm using imagemagick 6.9.5.9 on Archlinux. Ghostscript version is 9.19 (I don't know if IM uses GS for this or not).
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: ImageMagick CCITT Group4 pdf creation doesn't work anymore

Post by fmw42 »

You probably should provide and example input and output images, so that the IM developers can check it out.
leeeeeo
Posts: 7
Joined: 2016-09-23T16:52:38-07:00
Authentication code: 1151

Re: ImageMagick CCITT Group4 pdf creation doesn't work anymore

Post by leeeeeo »

Confirm.
Just run

Code: Select all

convert ./FzwRW-1.jpg -threshold 60% ./FzwRW-input_unprotected.pdf
and you will get normal (big) PDF.
With

Code: Select all

convert ./FzwRW-1.jpg -threshold 60% -compress Group4 ./FzwRW-input_unprotected.pdf
you will get a black page corrupted PDF.
MacOS with MacPorts.

Code: Select all

$ convert -version
Version: ImageMagick 6.9.5-9 Q16 x86_64 2016-09-15 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2016 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC Modules 
Delegates (built-in): bzlib djvu fftw fontconfig freetype gslib jbig jng jp2 jpeg lcms ltdl lzma openexr png ps tiff webp x xml zlib

Code: Select all

$ convert -list compress
B44
B44A
BZip
DXT1
DXT3
DXT5
Fax
Group4
JBIG1
JBIG2
JPEG
JPEG2000
Lossless
LosslessJPEG
LZMA
LZW
None
Piz
Pxr24
RLE
Zip
RunlengthEncoded
ZipS
Sample image.
Image
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: ImageMagick CCITT Group4 pdf creation doesn't work anymore

Post by fmw42 »

Your image is tiny. Perhaps you meant to provide a larger version. If I run your first command, I get a completely white image. When I add -compress group4, I still get a totally white image.

IM 6.9.5.10 Q16 Mac OSX Snow Leopard
leeeeeo
Posts: 7
Joined: 2016-09-23T16:52:38-07:00
Authentication code: 1151

Re: ImageMagick CCITT Group4 pdf creation doesn't work anymore

Post by leeeeeo »

It should be a 2.3MB image.
Trying another link:
https://dl.dropboxusercontent.com/u/150 ... zwRW-1.jpg
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: ImageMagick CCITT Group4 pdf creation doesn't work anymore

Post by fmw42 »

Both these commands work fine for me with your updated 2.3 MB image

Code: Select all

convert FzwRW-1.jpg -threshold 60% tmp1.pdf
convert FzwRW-1.jpg -threshold 60% -compress group4 tmp2.pdf
What version of libjpg and ghostscript are you using?

See that from

Code: Select all

convert -list format
and

Code: Select all

gs --version

I get for JPEG:

Code: Select all

     JPEG* JPEG      rw-   Joint Photographic Experts Group JFIF format (90)
      JPG* JPEG      rw-   Joint Photographic Experts Group JFIF format (90)
And for Ghostscript

Code: Select all

9.16
leeeeeo
Posts: 7
Joined: 2016-09-23T16:52:38-07:00
Authentication code: 1151

Re: ImageMagick CCITT Group4 pdf creation doesn't work anymore

Post by leeeeeo »

Here are the results:

Code: Select all

$ convert -list format | grep -i jpeg
           see part 5 which describes the image encoding (RLE, JPEG, JPEG-LS),
           and supplement 61 which adds JPEG-2000 encoding.
      J2C* JP2       rw-   JPEG-2000 Code Stream Syntax (2.1.0)
      J2K* JP2       rw-   JPEG-2000 Code Stream Syntax (2.1.0)
      JNG* PNG       rw-   JPEG Network Graphics
      JP2* JP2       rw-   JPEG-2000 File Format Syntax (2.1.0)
      JPC* JP2       rw-   JPEG-2000 Code Stream Syntax (2.1.0)
      JPE* JPEG      rw-   Joint Photographic Experts Group JFIF format (90)
     JPEG* JPEG      rw-   Joint Photographic Experts Group JFIF format (90)
      JPG* JPEG      rw-   Joint Photographic Experts Group JFIF format (90)
      JPM* JP2       rw-   JPEG-2000 Code Stream Syntax (2.1.0)
      JPS* JPEG      rw-   Joint Photographic Experts Group JFIF format (90)
      JPT* JP2       rw-   JPEG-2000 File Format Syntax (2.1.0)
    PJPEG* JPEG      rw-   Joint Photographic Experts Group JFIF format (90)

Code: Select all

$ gs --version
9.19
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: ImageMagick CCITT Group4 pdf creation doesn't work anymore

Post by fmw42 »

That should be fine. Sorry I do not know why you are having trouble. It works fine for me.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: ImageMagick CCITT Group4 pdf creation doesn't work anymore

Post by snibgo »

multixrulz wrote:convert input.png -despeckle -normalize -level 10%,90% -alpha off -monochrome -compress Group4 -quality 100 output.pdf
I suggest you find the simplest command that shows the problem. Does it occur for all output types or only PDF? Etc.
snibgo's IM pages: im.snibgo.com
leeeeeo
Posts: 7
Joined: 2016-09-23T16:52:38-07:00
Authentication code: 1151

Re: ImageMagick CCITT Group4 pdf creation doesn't work anymore

Post by leeeeeo »

Did some successful tests withing Windows ImageMagick through cygwin 64bit.

Code: Select all

leonardo@win81-virt ~/leonardo/Downloads/testDocs
$ convert -list format | grep -i jpeg
           see part 5 which describes the image encoding (RLE, JPEG, JPEG-LS),
           and supplement 61 which adds JPEG-2000 encoding.
      J2C* rw-   JPEG-2000 Code Stream Syntax (2.1.0)
      J2K* rw-   JPEG-2000 Code Stream Syntax (2.1.0)
      JNG* rw-   JPEG Network Graphics
      JP2* rw-   JPEG-2000 File Format Syntax (2.1.0)
      JPC* rw-   JPEG-2000 Code Stream Syntax (2.1.0)
     JPEG* rw-   Joint Photographic Experts Group JFIF format (80)
      JPM* rw-   JPEG-2000 Code Stream Syntax (2.1.0)
      JPT* rw-   JPEG-2000 File Format Syntax (2.1.0)
    PJPEG* rw-   Joint Photographic Experts Group JFIF format (80)

leonardo@win81-virt ~/leonardo/Downloads/testDocs
$ gs --version
9.19

leonardo@win81-virt ~/leonardo/Downloads/testDocs
$ convert -version
Version: ImageMagick 6.9.5-7 Q16 x86_64 2016-08-27 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2016 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC OpenMP
Delegates (built-in): autotrace bzlib cairo fftw fontconfig fpx freetype gslib jbig jng jp2 jpeg lzma pangocairo png ps rsvg tiff webp x xml zlib
Differences are:

Joint Photographic Experts Group JFIF format (80):In OS X is (90)
Version: ImageMagick 6.9.5-7 Q16 x86_64 2016-08-27: In OS X is ImageMagick 6.9.5-9 Q16 x86_64 2016-09-15
leeeeeo
Posts: 7
Joined: 2016-09-23T16:52:38-07:00
Authentication code: 1151

Re: ImageMagick CCITT Group4 pdf creation doesn't work anymore

Post by leeeeeo »

All of them works fine, except "fax" and "group4" (best compression for bitonal files).

Code: Select all

$ convert ./FzwRW-1.jpg -threshold 60% -compress JPEG2000 ./out.pdf
$ convert ./FzwRW-1.jpg -threshold 60% -compress B44 ./out.pdf
$ convert ./FzwRW-1.jpg -threshold 60% -compress B44A ./out.pdf
$ convert ./FzwRW-1.jpg -threshold 60% -compress BZip ./out.pdf
$ convert ./FzwRW-1.jpg -threshold 60% -compress DXT5 ./out.pdf
$ convert ./FzwRW-1.jpg -threshold 60% -compress Fax ./out.pdf
$ convert ./FzwRW-1.jpg -threshold 60% -compress LZMA ./out.pdf
$ convert ./FzwRW-1.jpg -threshold 60% -compress Piz ./out.pdf
$ convert ./FzwRW-1.jpg -threshold 60% -compress ZipS ./out.pdf
$ convert ./FzwRW-1.jpg -threshold 60% -compress Group4 ./out.pdf
leeeeeo
Posts: 7
Joined: 2016-09-23T16:52:38-07:00
Authentication code: 1151

Re: ImageMagick CCITT Group4 pdf creation doesn't work anymore

Post by leeeeeo »

One more relevant info on OS X (MacPorts) - workaround.

After uninstall last version (ImageMagick@6.9.5-9_0+x11) and activate ImageMagick @6.9.5-8_0+x11, PDF is correctly generated.

Code: Select all

$ sudo port uninstall ImageMagick@6.9.5-9_0+x11
--->  Deactivating ImageMagick @6.9.5-9_0+x11
--->  Cleaning ImageMagick
--->  Uninstalling ImageMagick @6.9.5-9_0+x11
--->  Cleaning ImageMagick
$ sudo port installed | grep Image
  ImageMagick @6.9.5-4_0+x11
  ImageMagick @6.9.5-8_0+x11
$ sudo port activate ImageMagick @6.9.5-8_0+x11
--->  Computing dependencies for ImageMagick
--->  Activating ImageMagick @6.9.5-8_0+x11
--->  Cleaning ImageMagick
leeeeeo
Posts: 7
Joined: 2016-09-23T16:52:38-07:00
Authentication code: 1151

Re: ImageMagick CCITT Group4 pdf creation doesn't work anymore

Post by leeeeeo »

Seems fixed in version: ImageMagick 6.9.5-10 Q16 x86_64 2016-09-26 http://www.imagemagick.org
multixrulz
Posts: 2
Joined: 2016-09-19T03:27:46-07:00
Authentication code: 1151

Re: ImageMagick CCITT Group4 pdf creation doesn't work anymore

Post by multixrulz »

Sorry for being uncommunicative, I was expecting to get email notifications.

It's fixed for me in 6.9.5.10 also.
Post Reply