Page 1 of 1

ImageMagick CCITT Group4 pdf creation doesn't work anymore

Posted: 2016-09-19T03:36:55-07:00
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).

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

Posted: 2016-09-19T11:14:52-07:00
by fmw42
You probably should provide and example input and output images, so that the IM developers can check it out.

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

Posted: 2016-09-23T17:06:15-07:00
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

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

Posted: 2016-09-23T18:04:50-07:00
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

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

Posted: 2016-09-23T18:30:24-07:00
by leeeeeo
It should be a 2.3MB image.
Trying another link:
https://dl.dropboxusercontent.com/u/150 ... zwRW-1.jpg

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

Posted: 2016-09-23T18:43:17-07:00
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

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

Posted: 2016-09-24T03:39:28-07:00
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

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

Posted: 2016-09-24T10:18:16-07:00
by fmw42
That should be fine. Sorry I do not know why you are having trouble. It works fine for me.

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

Posted: 2016-09-24T10:32:31-07:00
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.

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

Posted: 2016-09-24T12:07:18-07:00
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

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

Posted: 2016-09-24T12:11:39-07:00
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

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

Posted: 2016-09-24T12:27:19-07:00
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

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

Posted: 2016-09-26T05:22:37-07:00
by leeeeeo
Seems fixed in version: ImageMagick 6.9.5-10 Q16 x86_64 2016-09-26 http://www.imagemagick.org

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

Posted: 2016-10-20T01:48:39-07:00
by multixrulz
Sorry for being uncommunicative, I was expecting to get email notifications.

It's fixed for me in 6.9.5.10 also.