identify does not recognize Color Spaces properly

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.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: identify does not recognize Color Spaces properly

Post by magick »

Add -verbose to your identify command-line to see the Ghostscript command-line we leverage to render PDF. All rendering is performed by Ghostscript. We do some inspection of the PDF and if there were a reliable way to determine colorspace with shallow inspection, we could implement that.
pauloney
Posts: 22
Joined: 2016-11-02T15:40:36-07:00
Authentication code: 1151

Re: identify does not recognize Color Spaces properly

Post by pauloney »

magick wrote:Add -verbose to your identify command-line to see the Ghostscript command-line we leverage to render PDF. All rendering is performed by Ghostscript. We do some inspection of the PDF and if there were a reliable way to determine colorspace with shallow inspection, we could implement that.
It can't be "-verbose". I am already running every command with verbose and never seen a GS command flying by ....
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: identify does not recognize Color Spaces properly

Post by fmw42 »

try this

Code: Select all

convert -verbose im-bug.pdf null:
/var/tmp/magick-291dtVyqR5iohkp1 PNG 28x28 28x28+0+0 8-bit sRGB 181B 0.000u 0:00.000
im-bug.pdf PDF 28x28 28x28+0+0 16-bit sRGB 181B 0.000u 0:00.000
im-bug.pdf=> PDF 28x28 28x28+0+0 16-bit sRGB 181B 0.010u 0:00.070
[ghostscript library 9.16] -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 '-sDEVICE=pngalpha' -dTextAlphaBits=4 -dGraphicsAlphaBits=4 '-r72x72' '-sOutputFile=/var/tmp/magick-291dtVyqR5iohkp%d' '-f/var/tmp/magick-291Hg5YSp0a4QiO' '-f/var/tmp/magick-291hpgbB1SQNIqk'
pauloney
Posts: 22
Joined: 2016-11-02T15:40:36-07:00
Authentication code: 1151

Re: identify does not recognize Color Spaces properly

Post by pauloney »

Oh, I see, on "convert" not "identify" . Thank you Fred!

Now I see where many other wrong things about the image come from, like for example (on my PDF):

Format: PNG (Portable Network Graphics)
Mime type: image/png

The program is converting it into a PNG and then taking the information from the PNG ... I was curious about these errors as well ...

Is it just PS, EPS and PDF that are treated this way ?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: identify does not recognize Color Spaces properly

Post by fmw42 »

-sDEVICE=pngalpha
This is just the rendering device. You can change that in your delegates.xml file to pnmraw if you want. I do not know enough about Ghostscript to advise much in this situation. I do not see where you think you have a PNG image. The purpose of using pngalpha is so that GS can handle transparent PDF images. If you do not want that, you can change it to pnmraw.

But what I have in my delegates.xml file may be different from what you have and are using. So try my command on your system and see what it generates for the ghostscript command.

Ghostscript is used to process PS, PNG and EPS. I do not know what other formats it handles.
pauloney
Posts: 22
Joined: 2016-11-02T15:40:36-07:00
Authentication code: 1151

Re: identify does not recognize Color Spaces properly

Post by pauloney »

I understand, and I see that several things about size, etc ... can be inferred by the PNG produced by GS, but other properties are not - for example - it is wrong to run:

identify -verbose file.pdf

and get back something like we are getting right now:

Format: PNG (Portable Network Graphics)
Mime type: image/png

For these and others like Color Spaces we have to look at the PDF file raw.

I am going to work the algorithms as "magick" asked and send them over. Hopefully we can improve this a bit.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: identify does not recognize Color Spaces properly

Post by fmw42 »

Something is clearly wrong if you are getting Format: PNG from identify -verbose file.pdf, unless some one swapped a png suffix for a pdf suffix. Might the image have been created as a PDF, but a PNG suffix accidentally attached?
pauloney
Posts: 22
Joined: 2016-11-02T15:40:36-07:00
Authentication code: 1151

Re: identify does not recognize Color Spaces properly

Post by pauloney »

Nope, the image has nothing todo with a PNG, even the generation of it has nothing todo with a PNG. You can try on your own machine! Just download my example and run:

$ identify -verbose im-bug.pdf
Image: im-bug.pdf
Format: PNG (Portable Network Graphics)
Mime type: image/png
Class: DirectClass
Geometry: 28x28+0+0
Resolution: 72x72
......

and see the second and third lines of output.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: identify does not recognize Color Spaces properly

Post by fmw42 »

I do not get PNG:

Code: Select all

identify -verbose im-bug.pdf
Image: im-bug.pdf
  Format: PDF (Portable Document Format)
  Mime type: application/pdf
  Class: DirectClass
  Geometry: 28x28+0+0
  Resolution: 72x72
  Print size: 0.388889x0.388889
  Units: Undefined
  Type: PaletteAlpha
  Endianess: Undefined
  Colorspace: sRGB
  Depth: 16/8-bit
  Channel depth:
    red: 8-bit
    green: 8-bit
    blue: 8-bit
    alpha: 1-bit
There is something wrong with your IM compile if you get

Format: PNG

Have you tried re-installing or upgrading your IM version? What is your version of Ghostscript?

gs --version

Have you tried re-installing or upgrading your Ghostscript?

The other interesting thing is that PNG does not support CMYK.
pauloney
Posts: 22
Joined: 2016-11-02T15:40:36-07:00
Authentication code: 1151

Re: identify does not recognize Color Spaces properly

Post by pauloney »

Uoooo! that is interesting ....I am using GS 9.18 which is the latest available from Ubuntu 14.04 LTS. The problem is on 14.04 as well as 14.10 versions of Ubuntu.

$ identify -verbose cmyk.pdf | more
Image: cmyk.pdf
Format: PNG (Portable Network Graphics)
Mime type: image/png
Class: DirectClass
Geometry: 28x28+0+0
Resolution: 72x72
Print size: 0.388889x0.388889
Units: Undefined
Type: PaletteAlpha
Endianess: Undefined
Colorspace: sRGB

Can you tell me what version of gs are you running?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: identify does not recognize Color Spaces properly

Post by fmw42 »

9.16. But it may be a bad compile of IM.

What do you get from

convert -version

in terms of all your delegates.

P.S. I do not have cmyk.pdf. Have you uploaded it?
pauloney
Posts: 22
Joined: 2016-11-02T15:40:36-07:00
Authentication code: 1151

Re: identify does not recognize Color Spaces properly

Post by pauloney »

I get:

$ convert --version
Version: ImageMagick 6.8.9-9 Q16 x86_64 2016-06-01 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC
Features: DPC Modules OpenMP
Delegates: bzlib cairo djvu fftw fontconfig freetype jbig jng jpeg lcms lqr ltdl lzma openexr pangocairo png rsvg tiff wmf x xml zlib

and this is coming out of the Ununtu 14.04 LTS and 14.10.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: identify does not recognize Color Spaces properly

Post by fmw42 »

I do not see gs or gslib listed. That often means that you do not have ghostscript properly configured so that IM can find it. That also explains why you get PNG rather than PDF. I think an identify -verbose image.pdf might default to some other image format rather than PDF if ghostscript is not installed for IM.

I get ( Mac OSX )

Code: Select all

convert -version
Version: ImageMagick 6.9.6-3 Q16 x86_64 2016-10-31 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2016 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC Modules OpenMP
Delegates (built-in): bzlib cairo fftw fontconfig freetype gslib jbig jng jp2 jpeg lcms lqr ltdl lzma openexr png ps rsvg tiff webp x xml zlib


What do you get from:

Code: Select all

convert -verbose im-bug.pdf null:
pauloney
Posts: 22
Joined: 2016-11-02T15:40:36-07:00
Authentication code: 1151

Re: identify does not recognize Color Spaces properly

Post by pauloney »

I get:

Code: Select all

$ convert -verbose im-bug.pdf null:
"gs" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pngalpha" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r72x72"  "-sOutputFile=/tmp/magick-6840C2VyYtXdwttI%d" "-f/tmp/magick-6840iBaazpR5Dvkc" "-f/tmp/magick-684048SVkROOeJbG"
/tmp/magick-6840C2VyYtXdwttI1 PNG 28x28 28x28+0+0 8-bit sRGB 2.55KB 0.000u 0:00.000
im-bug.pdf PNG 28x28 28x28+0+0 16-bit sRGB 2.55KB 0.000u 0:00.009
im-bug.pdf=> PNG 28x28 28x28+0+0 16-bit sRGB 2.55KB 0.010u 0:00.040
and this is the case with a fresh install on Ubuntu 14.04 and 14.10.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: identify does not recognize Color Spaces properly

Post by fmw42 »

So IM seems to find gs. But oddly it is still reporting PNG. Very strange.

What do you now get from

Code: Select all

convert -version
Did you upgrade IM?


I get from the same command:

Code: Select all

convert -verbose im-bug.pdf null:
/var/tmp/magick-3006weXXd4811kCv1 PNG 28x28 28x28+0+0 8-bit sRGB 181B 0.000u 0:00.000
im-bug.pdf PDF 28x28 28x28+0+0 16-bit sRGB 181B 0.000u 0:00.000
im-bug.pdf=> PDF 28x28 28x28+0+0 16-bit sRGB 181B 0.010u 0:00.049
[ghostscript library 9.16] -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 '-sDEVICE=pngalpha' -dTextAlphaBits=4 -dGraphicsAlphaBits=4 '-r72x72'  '-sOutputFile=/var/tmp/magick-3006weXXd4811kCv%d' '-f/var/tmp/magick-3006rm3Li3muHvDt' '-f/var/tmp/magick-3006FN8ErWL7w38a'
Which shows PDF not PNG.

I am not sure what to tell you. I think one of the IM developers will need to look at this.
Post Reply