Page 1 of 1

Error "Got 2576-byte ICC profile not recognized as sRGB"

Posted: 2017-09-09T11:58:49-07:00
by Markson
I'm converting a PDF to JPG with ImageMagick 7.0.5-4 and GS Ghostscript 9.10 on Ubuntu 14.04

I'm getting error "Got 2576-byte ICC profile not recognized as sRGB" a way through the convert process.

I'm using

Code: Select all

convert -density 300  file.pdf -quality 91 file.jpg -debug all
But it's also erroring with any PDF and without the density, quality parameters, just on a simple convert.

and the process is getting to putting an extensionless PNG file (/tmp/magick-46841trokEvP3idC1) in the TMP directory, but then aborting after this error.

Code: Select all

2017-09-09T16:26:19+00:00 0:00.000 0.000u 7.0.5 Configure convert[4684]: utility.c/ExpandFilenames/943/Configure
  Command line: convert {-density} {300} {file.pdf} {-quality} {91} {file.jpg} {-debug} {all}
2017-09-09T16:26:19+00:00 0:00.000 0.000u 7.0.5 Configure convert[4684]: configure.c/GetConfigureOptions/688/Configure
  Searching for configure file: "/usr/local/share/ImageMagick-7/magic.xml"
2017-09-09T16:26:19+00:00 0:00.000 0.000u 7.0.5 Configure convert[4684]: configure.c/GetConfigureOptions/688/Configure
  Searching for configure file: "/usr/local/lib/ImageMagick-7.0.5//config-Q16HDRI/magic.xml"
2017-09-09T16:26:19+00:00 0:00.000 0.000u 7.0.5 Configure convert[4684]: configure.c/GetConfigureOptions/688/Configure
  Searching for configure file: "/usr/local/etc/ImageMagick-7/magic.xml"
2017-09-09T16:26:19+00:00 0:00.000 0.000u 7.0.5 Configure convert[4684]: configure.c/GetConfigureOptions/688/Configure
  Searching for configure file: "/usr/local/share/doc/ImageMagick-7/magic.xml"
2017-09-09T16:26:19+00:00 0:00.000 0.000u 7.0.5 Configure convert[4684]: configure.c/GetConfigureOptions/688/Configure
  Searching for configure file: "/root/.config/ImageMagick/magic.xml"
2017-09-09T16:26:19+00:00 0:00.000 0.000u 7.0.5 Configure convert[4684]: magic.c/LoadMagicCache/853/Configure
  Loading magic configure file "/usr/local/etc/ImageMagick-7/magic.xml" ...
2017-09-09T16:26:19+00:00 0:00.000 0.000u 7.0.5 Policy convert[4684]: policy.c/IsRightsAuthorized/601/Policy
  Domain: Path; rights=Read; pattern="file.pdf" ...
2017-09-09T16:26:19+00:00 0:00.010 0.000u 7.0.5 Blob convert[4684]: blob.c/OpenBlob/2986/Blob
    read 3 magic header bytes
2017-09-09T16:26:19+00:00 0:00.010 0.010u 7.0.5 Cache convert[4684]: cache.c/DestroyPixelCache/960/Cache
  destroy 
2017-09-09T16:26:19+00:00 0:00.010 0.010u 7.0.5 Policy convert[4684]: policy.c/IsRightsAuthorized/601/Policy
  Domain: Coder; rights=Read; pattern="PDF" ...
2017-09-09T16:26:19+00:00 0:00.010 0.010u 7.0.5 Policy convert[4684]: policy.c/IsRightsAuthorized/601/Policy
  Domain: Path; rights=Read; pattern="file.pdf" ...
2017-09-09T16:26:19+00:00 0:00.010 0.010u 7.0.5 Blob convert[4684]: blob.c/OpenBlob/2986/Blob
    read 3 magic header bytes
2017-09-09T16:26:19+00:00 0:00.010 0.010u 7.0.5 Resource convert[4684]: resource.c/AcquireUniqueFileResource/511/Resource
  ...
2017-09-09T16:26:19+00:00 0:00.010 0.010u 7.0.5 Resource convert[4684]: resource.c/AcquireUniqueFileResource/562/Resource
  /tmp/magick-4684A8ITBrfhjPRb
2017-09-09T16:26:19+00:00 0:00.010 0.010u 7.0.5 Resource convert[4684]: resource.c/RelinquishUniqueFileResource/1005/Resource
  /tmp/magick-4684A8ITBrfhjPRb
2017-09-09T16:26:19+00:00 0:00.010 0.010u 7.0.5 Exception convert[4684]: utility.c/ShredFile/1840/Exception
  Failed to remove: /tmp/magick-4684A8ITBrfhjPRb.cache
2017-09-09T16:26:19+00:00 0:00.010 0.010u 7.0.5 Resource convert[4684]: resource.c/AcquireUniqueFileResource/511/Resource
  ...
2017-09-09T16:26:19+00:00 0:00.010 0.010u 7.0.5 Resource convert[4684]: resource.c/AcquireUniqueFileResource/562/Resource
  /tmp/magick-4684A9a0wyrdCv2T
2017-09-09T16:26:19+00:00 0:00.010 0.010u 7.0.5 Configure convert[4684]: configure.c/GetConfigureOptions/688/Configure
  Searching for configure file: "/usr/local/share/ImageMagick-7/delegates.xml"
2017-09-09T16:26:19+00:00 0:00.010 0.010u 7.0.5 Configure convert[4684]: configure.c/GetConfigureOptions/688/Configure
  Searching for configure file: "/usr/local/lib/ImageMagick-7.0.5//config-Q16HDRI/delegates.xml"
2017-09-09T16:26:19+00:00 0:00.010 0.010u 7.0.5 Configure convert[4684]: configure.c/GetConfigureOptions/688/Configure
  Searching for configure file: "/usr/local/etc/ImageMagick-7/delegates.xml"
2017-09-09T16:26:19+00:00 0:00.010 0.010u 7.0.5 Configure convert[4684]: configure.c/GetConfigureOptions/688/Configure
  Searching for configure file: "/usr/local/share/doc/ImageMagick-7/delegates.xml"
2017-09-09T16:26:19+00:00 0:00.010 0.010u 7.0.5 Configure convert[4684]: configure.c/GetConfigureOptions/688/Configure
  Searching for configure file: "/root/.config/ImageMagick/delegates.xml"
2017-09-09T16:26:19+00:00 0:00.010 0.010u 7.0.5 Configure convert[4684]: delegate.c/LoadDelegateCache/2015/Configure
  Loading delegate configuration file "/usr/local/etc/ImageMagick-7/delegates.xml" ...
2017-09-09T16:26:19+00:00 0:00.010 0.010u 7.0.5 Resource convert[4684]: resource.c/AcquireUniqueFileResource/511/Resource
  ...
2017-09-09T16:26:19+00:00 0:00.010 0.010u 7.0.5 Resource convert[4684]: resource.c/AcquireUniqueFileResource/562/Resource
  /tmp/magick-46841trokEvP3idC
2017-09-09T16:26:19+00:00 0:00.010 0.010u 7.0.5 Resource convert[4684]: resource.c/RelinquishUniqueFileResource/1005/Resource
  /tmp/magick-46841trokEvP3idC
2017-09-09T16:26:19+00:00 0:00.010 0.010u 7.0.5 Exception convert[4684]: utility.c/ShredFile/1840/Exception
  Failed to remove: /tmp/magick-46841trokEvP3idC.cache
2017-09-09T16:26:21+00:00 0:01.410 1.400u 7.0.5 Resource convert[4684]: resource.c/RelinquishUniqueFileResource/1005/Resource
  /tmp/magick-4684A9a0wyrdCv2T
2017-09-09T16:26:21+00:00 0:01.410 1.400u 7.0.5 Exception convert[4684]: utility.c/ShredFile/1840/Exception
  Failed to remove: /tmp/magick-4684A9a0wyrdCv2T.cache
2017-09-09T16:26:21+00:00 0:01.410 1.400u 7.0.5 Resource convert[4684]: resource.c/RelinquishUniqueFileResource/1005/Resource
  /tmp/magick-4684A8ITBrfhjPRb
2017-09-09T16:26:21+00:00 0:01.410 1.400u 7.0.5 Exception convert[4684]: utility.c/ShredFile/1840/Exception
  Failed to remove: /tmp/magick-4684A8ITBrfhjPRb.cache
2017-09-09T16:26:21+00:00 0:01.410 1.400u 7.0.5 Policy convert[4684]: policy.c/IsRightsAuthorized/601/Policy
  Domain: Path; rights=Read; pattern="/tmp/magick-46841trokEvP3idC1" ...
2017-09-09T16:26:21+00:00 0:01.410 1.400u 7.0.5 Blob convert[4684]: blob.c/OpenBlob/2986/Blob
    read 3 magic header bytes
2017-09-09T16:26:21+00:00 0:01.410 1.400u 7.0.5 Cache convert[4684]: cache.c/DestroyPixelCache/960/Cache
  destroy 
2017-09-09T16:26:21+00:00 0:01.410 1.400u 7.0.5 Policy convert[4684]: policy.c/IsRightsAuthorized/601/Policy
  Domain: Coder; rights=Read; pattern="PNG" ...
2017-09-09T16:26:21+00:00 0:01.410 1.400u 7.0.5 Coder convert[4684]: png.c/ReadPNGImage/4348/Coder
  Enter ReadPNGImage()
2017-09-09T16:26:21+00:00 0:01.410 1.400u 7.0.5 Policy convert[4684]: policy.c/IsRightsAuthorized/601/Policy
  Domain: Path; rights=Read; pattern="/tmp/magick-46841trokEvP3idC1" ...
2017-09-09T16:26:21+00:00 0:01.410 1.400u 7.0.5 Blob convert[4684]: blob.c/OpenBlob/2986/Blob
    read 3 magic header bytes
2017-09-09T16:26:21+00:00 0:01.410 1.400u 7.0.5 Resource convert[4684]: resource.c/AcquireMagickResource/319/Resource
  Map: 1.365MB/1.302MiB/3.901GiB
2017-09-09T16:26:21+00:00 0:01.410 1.400u 7.0.5 Coder convert[4684]: png.c/ReadOnePNGImage/2401/Coder
    Enter ReadOnePNGImage()
    IM version     = 7.0.5-4
    Libpng version = 1.2.50
2017-09-09T16:26:21+00:00 0:01.410 1.400u 7.0.5 Coder convert[4684]: png.c/ReadOnePNGImage/2414/Coder
      Zlib version   = 1.2.8
2017-09-09T16:26:21+00:00 0:01.410 1.400u 7.0.5 Coder convert[4684]: png.c/ReadOnePNGImage/2446/Coder
      Before reading:
      image->alpha_trait=0      image->rendering_intent=2
      image->colorspace=23
      image->gamma=0.454545
2017-09-09T16:26:21+00:00 0:01.410 1.400u 7.0.5 Coder convert[4684]: png.c/ReadOnePNGImage/2735/Coder
      PNG width: 4267, height: 2133
    PNG color_type: 6, bit_depth: 8
    PNG compression_method: 0
    PNG interlace_method: 0, filter_method: 0
2017-09-09T16:26:21+00:00 0:01.410 1.400u 7.0.5 Coder convert[4684]: png.c/ReadOnePNGImage/2751/Coder
      Found PNG iCCP chunk.
2017-09-09T16:26:21+00:00 0:01.410 1.400u 7.0.5 Coder convert[4684]: png.c/ReadOnePNGImage/2819/Coder
      Reading PNG iCCP chunk.
2017-09-09T16:26:21+00:00 0:01.410 1.400u 7.0.5 Coder convert[4684]: png.c/ReadOnePNGImage/2883/Coder
      Got 2576-byte ICC profile not recognized as sRGB
Aborted
Any thoughts?

Re: Error "Got 2576-byte ICC profile not recognized as sRGB"

Posted: 2017-09-09T13:43:36-07:00
by glennrp
Get rid of the iCCP profile and replace it with the sRGB chunk or with a valid sRGB profile.
The complaint is ocming from libpng16.

The simplest way is to use the -strip option, if you haven't got any other valuable metadata that
you want to preserve (by the way, the -debug option should appear earlier on the commandline). Try

Code: Select all

convert -debug all -density 300  file.pdf -quality 91 -strip file.jpg
You'll still get the warning while reading the PDF but not during further processing of the *.jpg

If you don't mind editing and rebuilding ImageMagick, you can add

Code: Select all

    #if defined(PNG_SKIP_sRGB_CHECK_PROFILE) && \
        defined(PNG_SET_OPTION_SUPPORTED)
       png_set_option(png_ptr, PNG_SKIP_sRGB_CHECK_PROFILE,
           PNG_OPTION_ON);
    #endif
around line 2397 of ImagMagick-7.0.7-1/coders/png.c to avoid the sRGB check.

Re: Error "Got 2576-byte ICC profile not recognized as sRGB"

Posted: 2017-09-10T08:11:05-07:00
by Markson
Thanks Glenn.

I tried all three of your options options.

1. Profile

I took sRGB_ICC_v4_Appearance.icc from http://www.color.org/profiles/srgb_appearance.xalter and referenced it thus:

Code: Select all

convert -debug all file.pdf -profile sRGB_ICC_v4_Appearance.icc +profile * file.jpg
as I didn't know where to put the .icc file so I placed it in the same directory.

This didn't appear to work. despite jiggling different variations of +/-profile. I also tried to see if colorspace would help:

Code: Select all

convert -debug all -colorspace sRGB file.pdf -colorspace sRGB file.jpg
again with some permutations on RGB and sRGB

2. strip

I thought -strip would be a great solution, but I couldn't get it to work in single/multiple places in the command:

Code: Select all

convert -debug all -strip file.pdf -strip file.jpg -strip
3. Rewriting png.c

Code: Select all

  *zlib_runv='\0';
  (void) ConcatenateMagickString(zlib_runv,
         zlib_version,32);

    #if defined(PNG_SKIP_sRGB_CHECK_PROFILE) && \
     defined(PNG_SET_OPTION_SUPPORTED)
    png_set_option(png_ptr, PNG_SKIP_sRGB_CHECK_PROFILE,
        PNG_OPTION_ON);
    #endif

  logging=LogMagickEvent(CoderEvent,GetMagickModule(),
       "  Enter ReadOnePNGImage()\n"
       "    IM version     = %s\n"
       "    Libpng version = %s",
       im_vers, libpng_vers);
I located png.c and added the code, but I'm not awfully confident rebuilding packages on Ubuntu, so I am not sure if this would work. I hit a brick wall.

All the above resulted in the same error response with Aborted.

If you can spot any obvious errors or add pointers then I'd be grateful.

Thanks.

Re: Error "Got 2576-byte ICC profile not recognized as sRGB"

Posted: 2017-09-11T07:11:46-07:00
by Markson
There were 3 variants of ImageMagick on the server, so I uninstalled these together with GS, then reinstalled gs, then libgs-dev, then imagemagick and now I can convert PDF to any other format with impunity.

Thanks for your input Glenn.