Page 1 of 1
Merge tif containing tranparent layers results in white page
Posted: 2012-02-13T08:42:25-07:00
by straight
Hello,
as the title says, if a tif image containing transparent layers (e.g. saved in photoshop with option "save transparency") is merged, then the result image is plain white.
A simple convert to demonstrate:
Code: Select all
convert -layers merge imageWithTransparentLayers.tif merged.tif
Is this a bug or how can I handle this one?
Thanks in advance.
Greetings straight
Re: Merge tif containing tranparent layers results in white
Posted: 2012-02-13T10:58:35-07:00
by fmw42
I am not too sure what you are saying about your problem. Perhaps you could post links to your input an output images so we can see the problem and do testing. Also please always identify your IM version and platform when posting.
Possibly add -background none and read your input image before -layers merge
convert imageWithTransparentLayers.tif -background none -layers merge merged.tif
Re: Merge tif containing tranparent layers results in white
Posted: 2012-02-13T14:08:04-07:00
by straight
Version: ImageMagick 6.6.3-7 2010-08-18 Q16 (but I'm bind to this version)
Examples here. Please have a look.
tif with transperancy:
http://www.filetolink.com/fa1dcf7b
merged file:
http://www.filetolink.com/95a8e061
Your example doesn't work. The transparency in the picture will be black and the content is going tranparent...well that's weird.
Another try as follows works (object will still be untouched) but the transparency around will be black again.
Code: Select all
convert -alpha off -layers merge ImageWithTransparency.tif merged.tif
My purpose is a flatten tif which looks exactly the same as the original (e.g. opened in Photoshop). Layers should be merged and transparency retained.
Again, the only problem is if the tif is saved out of photoshop with the option "save transparency".
I'm desperate. TIA.
Greetings straight
Re: Merge tif containing tranparent layers results in white
Posted: 2012-02-13T14:50:17-07:00
by fmw42
My purpose is a flatten tif which looks exactly the same as the original (e.g. opened in Photoshop). Layers should be merged and transparency retained.
First off, PS uses background transparency and alpha transparency (two kinds). IM only has alpha transparency. So PS background transparency is converted to alpha transparency in IM.
There is no way that I know to flatten the tiff image in IM so that you convert the alpha transparency to background transparency or make some color into transparent so as to remove the alpha channel and save as tiff.
Your image only has one RGBA frame/layer. And your alpha channel is nearly binary with a little anti-aliasing at the edges. So try
convert ImageWithTransparency.tiff -background black -flatten result
This will make your image look correct where not fully transparent and the rest will be black.
If you want to use another background color then use -background somecolor. The default is white, I believe. If you use -background none, you will not be removing the alpha channel. The image will retain its transparency and be identical to your original
There is no way to "merge" the alpha channel with the image without using/picking a background color. Alternately, you can make a checkerboard image of the same size and flatten your image onto the checkerboard so that it looks similar to what you see in PS with background transparency.
If I misunderstand what you mean by merging, please clarify.
Re: Merge tif containing tranparent layers results in white
Posted: 2012-02-15T21:34:33-07:00
by anthony
straight wrote:A simple convert to demonstrate:
Code: Select all
convert -layers merge imageWithTransparentLayers.tif merged.tif
WARNING: this command will likely fail in IMv7. You muse read in an image before tryiing to change the image!
Also you should be specifying a
-background color on which all the 'layers' are to be flattened against. For example a 'none' or transparent color. Of course background color does not matter if the first image layer is fully opaque!
Code: Select all
convert imageWithTransparentLayers.tif -background None -layers flatten flattened.tif
Re: Merge tif containing tranparent layers results in white
Posted: 2012-03-08T02:26:19-07:00
by straight
Finally,
I come up with this issue again and tried nearly every combination and find myself a solution that will work.
As fmw42 recognized correctly is, that there are two kinds of transperancy alpha and background. And this was the problem. Using -layers merge also merges the alpha channel and paint it in a color like black or white. So I just disable alpha channel first before merge.
I know, that I will lose the transparency but this isn't so bad because I got a clipping path to mask the motive in the image again.
So all in all I'm using this one:
Code: Select all
convert imageWithTransparentLayers.tif -alpha off -transparent none -layers merge -alpha on +clip-path '#1' -fill none -background none -draw "color 0,0 reset" merged.png
edit: After merge, alpha have to be enabled to fill the outer clipping path to none (transparent)
anthony wrote:
WARNING: this command will likely fail in IMv7. You muse read in an image before tryiing to change the image!
Thanks for the advise. That means no difference in result of
convert -alpha off image.tif out.tif
and
convert image.tif -alpha off out.tif
Thanks for your suggestions.
Greetings straight
Re: Merge tif containing tranparent layers results in white page
Posted: 2015-07-27T00:48:27-07:00
by babinlal
I used the above code and getting "Error - Unsupported bits/sample" in IE - AlternaTIFF. Could anyone please help me to solve this?
Re: Merge tif containing tranparent layers results in white page
Posted: 2015-07-27T09:54:06-07:00
by fmw42
Please identify which code? Also provide your version of IM and platform? Also if possible upload your image to dropbox.com and put the URL here so we can test. Please read the very first post at the top of the the Users forum regarding how to ask questions..