Page 1 of 1

RESOLVED: possible bug extracting the transparency from CMYK TIFF

Posted: 2015-08-30T13:40:16-07:00
by fmw42
See the Original.tif image at viewtopic.php?f=1&t=28259#p125180. It is a CMYK TIF with background transparency.

I cannot seem to extract the background transparency in IM using:

Code: Select all

convert Original.tif -alpha extract show:
It is totally white. Using PS to view it, there is background transparency. But none of the other viewers I have, seem to show transparency (tried GraphicConvert, Mac Preview, IM display).

IM display does not show the correct colors for CMYK, also. They appear to be negated, but when I negate the image, the colors are wrong. I get orange where it should be brown.

This is the same image as with the other CMYK bug converting to sRGB.


I had hoped that this might convert correctly and preserve the transparency. But it did not due the problem above.

Code: Select all

convert Original.tif[0] \
\( -clone 0 -alpha extract \) \
\( -clone 0 +profile "*" \
	-profile /Users/fred/images/profiles/USWebCoatedSwop.icc \
	-profile /Users/fred/images/profiles/sRGB.icc \) \
-delete 0 +swap -alpha off -compose copy_opacity -composite Original_rgb5.tif

Re: possible bug extracting the transparency from CMYK TIFF

Posted: 2015-08-30T16:30:35-07:00
by magick
Try
  • convert Original.tif image.miff
    display image.miff
The second image is transparent. Is that what you are looking for?

Re: possible bug extracting the transparency from CMYK TIFF

Posted: 2015-08-30T18:41:39-07:00
by 246246
magick wrote:Try
  • convert Original.tif image.miff
    display image.miff
The second image is transparent. Is that what you are looking for?
Surprised this works. (display image.miff[1] shows background transparent image.)

But then, why

Code: Select all

identify -quiet Original.tif[1]
doesn't work? (no output)

Or

Code: Select all

> convert -quiet Original.tif[1] image.tif
convert.exe: no images defined `image.tif' @ error/convert.c/ConvertImageCommand
/3230.
generate nothing.

Re: possible bug extracting the transparency from CMYK TIFF

Posted: 2015-08-30T18:42:01-07:00
by fmw42
magick wrote:Try

convert Original.tif image.miff
display image.miff
The second image is transparent. Is that what you are looking for?
Yes, that should do it.

But when I try to extract the alpha channel from the second layer and compose it over the first layer converted to sRGB, the final composite (tmp3.png) is bad (offsets between the two images). Yet, if I save the two images to disk and do the composite as tmp4.png, it works fine.

Code: Select all

identify Original.tif
Original.tif[0] TIFF 1200x1200 1200x1200+0+0 8-bit CMYK 6.542MB 0.000u 0:00.000
Original.tif[1] TIFF 1140x696 1140x696+30+252 8-bit CMYK 0.000u 0:00.000
This fails:

Code: Select all

convert -quiet Original.tif \
\( -clone 1 +profile "*" -alpha extract \( -size 1200x1200 xc:black \) \
	+swap -layers merge +repage +write tmp1.png \
	-format "%wx%h %P%O %[colorspace]\n" -write info: \) \
\( -clone 0 +profile "*" -alpha off \
	-profile /Users/fred/images/profiles/USWebCoatedSwop.icc \
	-profile /Users/fred/images/profiles/sRGB.icc +repage +write tmp2.png \
	-format "%wx%h %P%O %[colorspace]\n" -write info: \) \
-delete 0 +swap +repage -alpha off \
-compose over -compose copy_opacity -composite \
-format "%wx%h %P%O %[colorspace]\n" -write info: tmp3.png
Information listed to terminal:

1200x1200 0x0+0+0 sRGB
1200x1200 0x0+0+0 sRGB
1140x696 0x0+0+0 CMYK

Why is the composite smaller than the two images?
Why is the Page Geometry 0x0?
Why is the composite CMYK when the two images are sRGB?


But this works fine:

Code: Select all

convert tmp2.png tmp1.png -alpha off -compose copy_opacity -define tiff:alpha=associated-composite tmp4.png

Re: possible bug extracting the transparency from CMYK TIFF

Posted: 2015-08-31T10:58:39-07:00
by fmw42
OK. I figured out my mistake. I needed to delete both layers of the input at the end. So this now works.

Code: Select all

convert -quiet -respect-parenthesis Original.tif \
\( -clone 0 -evaluate set 0 \) \
\( -clone 1 -alpha extract \) \
\( -clone 2 -clone 3 -layers merge +repage \) \
-delete 2,3 \
\( -clone 0 +profile tiff:37724 -alpha off \
	-profile /Users/fred/images/profiles/USWebCoatedSwop.icc \
	-profile /Users/fred/images/profiles/sRGB.icc +repage \) \
-delete 0,1 \
+swap -alpha off -compose copy_opacity -composite \
-define tiff:alpha=associated  \
Original_srgb.tif