Page 3 of 4
Re: converting cmyk tif with background transparency to rgb tiff
Posted: 2015-08-30T18:50:47-07:00
by fmw42
My point is that only PS shows the transparency. That is a problem, if other viewers including IM do not show the transparency. That is why this is an IM bug.
EDIT: Also your command produces the wrong colors when viewed in PS (orange rather than brown), though it looks fine in other viewers, except the transparency is gone as in not showing in those viewers (white rather than transparent)
Re: converting cmyk tif with background transparency to rgb tiff
Posted: 2015-08-30T19:25:43-07:00
by 246246
fmw42 wrote:My point is that only PS shows the transparency. That is a problem, if other viewers including IM do not show the transparency. That is why this is an IM bug.
I know there exists such tif. But I don't think it can be said it is definitely IM bug at least for display. Because it is not a tiff standard.
When converting, there should be a way to handle it somehow.
fmw42 wrote:
EDIT: Also your command produces the wrong colors when viewed in PS (orange rather than brown), though it looks fine in other viewers, except the transparency is gone as in not showing in those viewers (white rather than transparent)
Convert from tif, your are right. But i said it again, what i wrote is convert
from psd. It looks brown in PS.
If you see still orange when converting from psd, it might be a Photoshop version difference.
Re: converting cmyk tif with background transparency to rgb tiff
Posted: 2015-08-30T19:52:47-07:00
by fmw42
No, the problem is not with PS, but with IM conversion of the TIFF.
Re: converting cmyk tif with background transparency to rgb tiff
Posted: 2015-08-30T19:56:55-07:00
by 246246
fmw42 wrote:No, the problem is not with PS, but with IM conversion of the TIFF.
i am talking about this command
viewtopic.php?f=1&t=28259&start=15#p125385
Is this conversion result orange tiff in Photoshop?
Re: converting cmyk tif with background transparency to rgb tiff
Posted: 2015-08-30T20:09:49-07:00
by fmw42
see
viewtopic.php?f=1&t=28259&start=15#p125405
There is no PSD in this topic. You may have converted to PSD in PS, but that is irrelevant to this issue. The issue has to do with conversion of CMYK TIFF to sRGB TIFF in IM. By converting to PSD in PS, you have avoided the issue and probably get correct results. Once it is PSD, IM may not have any problems.
Re: converting cmyk tif with background transparency to rgb tiff
Posted: 2015-08-30T20:41:24-07:00
by 246246
OK I'd like to know if this work in your environment, because you said "it doesn't work" without any quote.
I did not say that worked. I only said that can strip xmp metadata.
fmw42 wrote:
There is no PSD in this topic.
Yes, but look carefully. Currently I need Photoshop to do this conversion.
But when transparency lock issue would be fixed, it could be correct conversion will be archived without Photoshop.
And remember the contents of tiff 37742 tag is almost like a psd format. And therefore, tiff.c relies on psd.c. So you cannot say it is totally irrelevant. Currently, psd to tiff succeeded, but equivalent tiff to tiff failed. I think It is good starting point to check the source code.
Re: converting cmyk tif with background transparency to rgb tiff
Posted: 2015-08-30T22:31:43-07:00
by 246246
wellyman1 wrote:should I go back to approaching it this way? it did produce the desired result
convert Original.tif -alpha off /Users/tewellman/profiles/sRGB.icc -alpha on rgbout6.tif
It does not convert it to RGB at all.
Code: Select all
> identify rgbout6.tif
rgbout6.tif[0] TIFF 1200x1200 1200x1200+0+0 8-bit CMYK 12.63MB 0.016u 0:00.006
rgbout6.tif[1] TIFF 1140x696 1140x696+30+252 8-bit CMYK 12.63MB 0.000u 0:00.010
rgbout6.tif[2] TIFF 1x1 1x1+0+0 16-bit Grayscale Gray 12.63MB 0.000u 0:00.020
rgbout6.tif[2] comes from sRGB.icc treated as a file.
rgbout6[0] is exactly same as Original.tif[0]. No conversion is performed.
Code: Select all
> compare -quiet -metric PSNR Original.tif[0] rgbout6.tif[0] null:
1.#INF
Re: converting cmyk tif with background transparency to rgb tiff
Posted: 2015-08-30T23:30:19-07:00
by fmw42
Re: converting cmyk tif with background transparency to rgb tiff
Posted: 2015-08-31T06:30:26-07:00
by 246246
Interesting. Inspired from magick's suggestion, my current solution would be:
Code: Select all
convert -quiet Original.tif psd:- | convert - -gravity center -compose CopyOpacity -composite +profile xmp +profile tiff:37724 -profile sRGB.icc o.tif
Then It becomes to standard tiff.
Re: converting cmyk tif with background transparency to rgb tiff
Posted: 2015-08-31T09:05:38-07:00
by wellyman1
If I open the original in photoshop and save it without layers with transparency I can convert it fine with
Code: Select all
convert orig_saved_wo_layers_w_tx.tif -profile /Users/tewellman/profiles/sRGB.icc orig_saved_wo_layers_w_tx_out.tif
If I open the original in photoshop and save it with layers with transparency I get the orange color when I try to convert.
Code: Select all
convert orig_with_layers_w_tx.tif -profile /Users/tewellman/profiles/sRGB.icc orig_with_layers_w_tx_out.tif
To get it to work with layers, I convert to psd then to tif
Code: Select all
convert orig_with_layers_w_tx.tif -profile /Users/tewellman/profiles/sRGB.icc orig_with_layers_w_tx_out.psd
convert orig_with_layers_w_tx_out.psd orig_with_layers_w_tx_out.tif
Of course all of these examples are based on me opening the file in photoshop and saving it out with transparency, which I think is giving it a true alpha channel.
https://www.dropbox.com/s/ljwpz1dwklr02 ... x.png?dl=0
https://www.dropbox.com/s/nskckwrf15jnx ... x.tif?dl=0
https://www.dropbox.com/s/64nkhao1a4t8p ... x.tif?dl=0
Re: converting cmyk tif with background transparency to rgb tiff
Posted: 2015-08-31T09:53:19-07:00
by fmw42
246246 wrote:Interesting. Inspired from magick's suggestion, my current solution would be:
Code: Select all
convert -quiet Original.tif psd:- | convert - -gravity center -compose CopyOpacity -composite +profile xmp +profile tiff:37724 -profile sRGB.icc o.tif
Then It becomes to standard tiff.
That is a good thought. But it loses the proper transparency. The transparency is only outside the whole rectangle of the logo and does not properly mask the boundary of the logo.
See my solution at
viewtopic.php?f=3&t=28281#p125416. The direct method fails, but if one saves the two images and does another convert on them it works. Cleaning my code up, it becomes
Code: Select all
convert -quiet -respect-parenthesis Original.tif \
\( -clone 1 +profile tiff:37724 -alpha extract \( -size 1200x1200 xc:black \) \
+swap -layers merge +repage +write tmp1.png \) \
\( -clone 0 +profile tiff:37724 -alpha off \
-profile /Users/fred/images/profiles/USWebCoatedSwop.icc \
-profile /Users/fred/images/profiles/sRGB.icc +repage +write tmp2.png \) \
null:
convert tmp2.png tmp1.png -alpha off -compose copy_opacity -composite -define tiff:alpha=associated result.tif
Re: converting cmyk tif with background transparency to rgb tiff
Posted: 2015-08-31T10:57:15-07:00
by fmw42
This works now as one command.
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
Re: converting cmyk tif with background transparency to rgb tiff
Posted: 2015-08-31T12:11:08-07:00
by wellyman1
I was able to run this successfully.
Re: converting cmyk tif with background transparency to rgb tiff
Posted: 2015-09-01T11:14:32-07:00
by wellyman1
Thanks for all the help! This looks promising but I am not out of the woods yet. I am eventually going to incorporate this into a Magick.net app where the user provides files. So I will not know the number of layers before hand.
How would I modify this command to account for when a tiff has multiple layers?
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
I am using this as a test and am not getting the desired result.
https://www.dropbox.com/s/ufsv534m6g1ud ... r.tif?dl=0
Re: converting cmyk tif with background transparency to rgb tiff
Posted: 2015-09-01T12:49:14-07:00
by fmw42
Sorry, I cannot answer your question about modifying the code above, because my old PS (CS) will not open that file saying it is not a valid text layer. Probably my old PS is just too old for this type of TIFF.
With this new file, identify lists 3 layers.
identify orig_multi_layer.tif
orig_multi_layer.tif[0] TIFF 1200x1200 1200x1200+0+0 8-bit CMYK 6.583MB 0.000u 0:00.000
orig_multi_layer.tif[1] TIFF 1140x696 1140x696+30+252 8-bit CMYK 0.000u 0:00.000
orig_multi_layer.tif[2] TIFF 596x208 596x208+291+382 8-bit CMYK 0.000u 0:00.000
With your previous file, it lists two layers, because (I think) it is due to the transparency.
If you had no transparency, you would get one layer.
But I do not know how to detect if you have two layers whether it is transparent or not other than
Code: Select all
convert -quite orig_multi_layer.tif -format "%[channels] %A %[type]\n" info:
cmyk False ColorSeparation
cmyka True ColorSeparationAlpha
cmyka True ColorSeparationAlpha
You can see this way which layers have transparency or not.