possible bug maintaining transparency IM 6.8.6.8 Q16

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
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

possible bug maintaining transparency IM 6.8.6.8 Q16

Post by fmw42 »

With regard to the post at viewtopic.php?f=1&t=23954, I believe the gist of the issue is as follows.

The input image at https://docs.google.com/file/d/0B8WNVy3 ... sp=sharing
is a CMYK .ai image with background transparency (according to Photoshop).


When converting from CMYK to sRGB using -colorspace, the resulting tif has transparency.

convert -density 300 -colorSpace sRGB logo.ai -trim +repage test2_rgb.tif


But when converting from CMYK to RGB (sRGB) using profiles, the resulting tiff has lost the transparency and has a white background.

convert -density 300 logo.ai -trim +repage -profile /Users/fred/images/profiles/USWebCoatedSWOP.icc -profile /Users/fred/images/profiles/sRGB.icc test_rgb.tif


Is this a bug or something that we do not understand about using profiles?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: possible bug maintaining transparency IM 6.8.6.8 Q16

Post by magick »

Add -verbose to your command line and you'll see the answer to your question. ImageMagick leverages Ghostscript to render Postscript, AI, PDF, etc., image files. The -colorspace sRGB option tells Ghostscript to use the PNGALPHA device which supports an alpha channel. Without this option, the logo.ai file is rendered as CMYK with the PAM output device. Although PAM should be able to support CMYKA, it apparently is not supported by Ghostscript. It would be grand if Ghostscript had an output device that supported all the various pixel formats such as RGB, RGBA, CMYK, and CMYKA-- but it doesn't.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: possible bug maintaining transparency IM 6.8.6.8 Q16

Post by fmw42 »

So am I correct that one could edit the delegates.xml file from


<delegate decode="ps:cmyk" stealth="True" command=""gs" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pam" -dTextAlphaBits=%u -dGraphicsAlphaBits=%u "-r%s" %s "-sOutputFile=%s" "-f%s" "-f%s""/>


to


<delegate decode="ps:cmyk" stealth="True" command=""gs" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pngalpha" -dTextAlphaBits=%u -dGraphicsAlphaBits=%u "-r%s" %s "-sOutputFile=%s" "-f%s" "-f%s""/>

And that would work with profiles?


P.S. I would try that, but I seem to have several directories

/usr/local/etc/ImageMagick/delegates.xml
/usr/local/etc/ImageMagick-6/delegates.xml
/usr/local/etc/ImageMagick-6.8/delegates.xml
/usr/local/share/doc/ImageMagick/www/source/delegates.xml
/usr/local/share/doc/ImageMagick-6/www/source/delegates.xml
/usr/local/share/doc/ImageMagick-6.8/www/source/delegates.xml


Which is the correct one and can the other (similar directories) be deleted?

The resources page lists these as searched:

$MAGICK_CONFIGURE_PATH
$PREFIX/etc/ImageMagick
$PREFIX/share/ImageMagick-6.8.6
$HOME/.magick/
<client path>/etc/ImageMagick/

So does that mean the the first one found, namely, /usr/local/etc/ImageMagick/delegates.xml would be the one that is actually used?
Last edited by fmw42 on 2013-08-22T18:20:46-07:00, edited 1 time in total.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: possible bug maintaining transparency IM 6.8.6.8 Q16

Post by magick »

Edit /usr/local/etc/ImageMagick-6/delegates.xml. Delete the others.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: possible bug maintaining transparency IM 6.8.6.8 Q16

Post by fmw42 »

magick wrote:Edit /usr/local/etc/ImageMagick-6/delegates.xml. Delete the others.

Please clarify, since (while you were posting your answer) I edited my post above to show the load order from the resource page and it would appear from that, that the one to use would be $PREFIX/etc/ImageMagick = /usr/local/etc/ImageMagick

Does it stop at the first or last file in the resource list?

Thanks
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: possible bug maintaining transparency IM 6.8.6.8 Q16

Post by magick »

/usr/local/etc/ImageMagick is left over from installing an older version of ImageMagick. The latest releases look for /usr/local/etc/ImageMagick-6.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: possible bug maintaining transparency IM 6.8.6.8 Q16

Post by fmw42 »

Thanks.

So I should also delete /usr/local/etc/ImageMagick-6.8/ ?


Similarly for

/usr/local/share/doc/ImageMagick/www/source/delegates.xml
/usr/local/share/doc/ImageMagick-6/www/source/delegates.xml
/usr/local/share/doc/ImageMagick-6.8/www/source/delegates.xml

Just keep this ?

/usr/local/share/doc/ImageMagick-6
Last edited by fmw42 on 2013-08-23T10:25:01-07:00, edited 1 time in total.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: possible bug maintaining transparency IM 6.8.6.8 Q16

Post by magick »

Yes. The location was changed based on recommendations from the Debian maintainers.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: possible bug maintaining transparency IM 6.8.6.8 Q16

Post by fmw42 »

magick wrote:Yes. The location was changed based on recommendations from the Debian maintainers.

OK. Should the resource page be updated, which shows

$MAGICK_CONFIGURE_PATH
$PREFIX/etc/ImageMagick
$PREFIX/share/ImageMagick-6.8.6
$HOME/.magick/
<client path>/etc/ImageMagick/
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: possible bug maintaining transparency IM 6.8.6.8 Q16

Post by magick »

Done.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: possible bug maintaining transparency IM 6.8.6.8 Q16

Post by fmw42 »

To make the example work with profiles and maintain transparency. Do the following:

1) Edit your delegates.xml file in $PREFIX/etc/ImageMagick-6
(on my system that would be /usr/local/etc/ImageMagick-6/delegates.xml)

and change sDevice=pam to sDevice=pngalpha for ps:cmyk

<delegate decode="ps:cmyk" stealth="True" command=""gs" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pngalpha" -dTextAlphaBits=%u -dGraphicsAlphaBits=%u "-r%s" %s "-sOutputFile=%s" "-f%s" "-f%s""/>

Save the file


2) run your command, such as

convert -density 300 logo.ai -trim +repage -profile /Users/fred/images/profiles/USWebCoatedSWOP.icc -profile /Users/fred/images/profiles/sRGB.icc test_rgb.tif


The result test.rgb.tif will not have a transparent background.

The above worked fine for me on IM 6.8.6.8 Q16. Note that the location for the delegates.xml file has changed as magick wrote above. So if you have an earlier version than 6.8.6.x it may be elsewhere in one of the directories I mentioned above. You should be able to locate all of the delegates.xml file using

find /usr | grep "delegates.xml"
User avatar
eduardo.melgar
Posts: 15
Joined: 2013-08-21T05:08:29-07:00
Authentication code: 6789

Re: possible bug maintaining transparency IM 6.8.6.8 Q16

Post by eduardo.melgar »

Thank you. I did as explained and finally got the required transparency. But after I changed the setting, color space is not correctly described by identify.

Running following command:

$ identify -verbose profile_USWCv2.eps

Here, the original description (correct):

Image: profile_USWCv2.eps
Format: EPT (Encapsulated PostScript with TIFF preview)
Class: DirectClass
Geometry: 535x355+0+0
Base geometry: 2231x1480
Resolution: 300x300
Print size: 1.78333x1.18333
Units: Undefined
Type: ColorSeparation
Base type: ColorSeparation
Endianess: Undefined
Colorspace: CMYK
Depth: 16/8-bit
...
Profiles:
Profile-icc: 557168 bytes
Description: U.S. Web Coated (SWOP) v2
Manufacturer: U.S. Web Coated (SWOP) v2
Model: U.S. Web Coated (SWOP) v2
Copyright: Copyright 2000 Adobe Systems, Inc.

Here the new identify-description (incorrect)

Image: profile_USWCv2.eps
Format: EPT (Encapsulated PostScript with TIFF preview)
Class: DirectClass
Geometry: 535x355+0+0
Base geometry: 2231x1480
Resolution: 300x300
Print size: 1.78333x1.18333
Units: Undefined
Type: TrueColorAlpha
Endianess: Undefined
Colorspace: sRGB
...
Profiles:
Profile-icc: 557168 bytes
Description: U.S. Web Coated (SWOP) v2
Manufacturer: U.S. Web Coated (SWOP) v2
Model: U.S. Web Coated (SWOP) v2
Copyright: Copyright 2000 Adobe Systems, Inc.


As you can see, the file is definitely CMYK (with embedded profile), but 'identify' mark it as 'sRGB'
Post Reply