flattening tiff with layermask on it

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: flattening tiff with layermask on it

Post by fmw42 »

Your old version does not support the -alpha commands. They were added around 6.4.3-7.

Alternates for older systems

convert bob.tif +matte bob_aoff.tif

convert bob.tif -channel A -separate +channel -negate bob_alpha.tif
db2346
Posts: 16
Joined: 2011-09-29T14:32:10-07:00
Authentication code: 8675308

Re: flattening tiff with layermask on it

Post by db2346 »

OK, changing course on this. We can not install the latest version on the redhat boxes. not even the latest redhat box has the right version of IM. Looks like porting the files off to a mac for the processing unless someone actually knows how to pull this off.

Hate to do this but I am on a deadline and since i doubt the people at redhat will help with all the dependencies, I am stuck with this.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: flattening tiff with layermask on it

Post by fmw42 »

Did you try my commands for older systems above? Do they work to show you the issue? If not I can post these two images for your review.
db2346
Posts: 16
Joined: 2011-09-29T14:32:10-07:00
Authentication code: 8675308

Re: flattening tiff with layermask on it

Post by db2346 »

Yes, I did and the results were the same. They did however work fine on a mac. sorry I could not move forward on the redhat box. saw in one discussion a bug in a earlier version of IM that suggested it used 254 to calculate grey scale alpha channels or something like that. not sure what he was getting at but since i have a mac on the network and redhad is still today not using the latest version of IM, I thought i needed to solve the problem already. boss not too keen on the time i have spent trying to solve it. i should have already moved to a solution.

thanks for the help though. this has been a learning experiacne and I am definitly looking at a chance to use IM in the future.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: flattening tiff with layermask on it

Post by fmw42 »

For what it is worth, here are the two images I extracted from your bob.tiff -- the underlying image and alpha channel. The problem is that the underlying image has a broad white outline drawn on it that has rather ragged edges which show through when the alpha channel is overlaid. The alpha channel outline is very smooth.

underlying image:
http://www.fmwconcepts.com/misc_tests/b ... b_aoff.tif

alpha channel:
http://www.fmwconcepts.com/misc_tests/b ... _alpha.tif
db2346
Posts: 16
Joined: 2011-09-29T14:32:10-07:00
Authentication code: 8675308

Re: flattening tiff with layermask on it

Post by db2346 »

I am sorry, I did run these and saw the difference. I saw that you ended up with both of those results but I did not see how it would aid me in applying the mask to the image as I needed. Forgive me if I am missing something fundamental here that you where trying ti show me that would allow me to solve my problem.

did I simply not understand what you were trying to show me?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: flattening tiff with layermask on it

Post by fmw42 »

db2346 wrote:I am sorry, I did run these and saw the difference. I saw that you ended up with both of those results but I did not see how it would aid me in applying the mask to the image as I needed. Forgive me if I am missing something fundamental here that you where trying ti show me that would allow me to solve my problem.

did I simply not understand what you were trying to show me?

Perhaps I misunderstand what you are trying to do. I had thought that the white outline is the cause of the rough aliasing you are seeing when the alpha channel is in the image. That is it bleeds through. I thought that if you had the image without the white outline in it, then you would not see the jagged aliasing in your result because it is coming from the white outline and not the alpha channel.

If I misunderstand your problem, the please clarify. But as far as I can see the white outline is the problem and not the alpha channel. Why is the white outline in the image at all? You seem to be trying to cover over it with the alpha channel so that one does not see it. So why not just make the underlying image without the broad white outline.
db2346
Posts: 16
Joined: 2011-09-29T14:32:10-07:00
Authentication code: 8675308

Re: flattening tiff with layermask on it

Post by db2346 »

actually the white outline does not exist in the original image as far as I can see.

however, it occurs to me that is I extract the alpha channel like what you did and then i take the image and extract the alpha channel. and I do the opposite with the image so I have the 2 separate files, invert the alpha channel and overly it set to lighten, I will essentially do what I want will I not?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: flattening tiff with layermask on it

Post by fmw42 »

db2346 wrote:actually the white outline does not exist in the original image as far as I can see.

It is there as far as IM is concerned? So where does it come from? How are you viewing it with the alpha channel off? Can it be some other layer that is getting imbedded in the image when IM removes the alpha channel?

I don't see it when viewing in PS CS (rather old). So it would appear that IM is having some issue with that tiff image ( which has a mask channel and a mask layer which seems atypical). Perhaps it is in the meta data, but -strip does not remove it.
db2346
Posts: 16
Joined: 2011-09-29T14:32:10-07:00
Authentication code: 8675308

Re: flattening tiff with layermask on it

Post by db2346 »

I can view it in photoshop cs 3-5 on various machines and I do not see it anyplace. weird........

OK, so I have a question, can I apply this mask in IM?

i actually have the image without the mask applied. al the mask are named the same, goal is still the same, to have the mask applies with a white back ground. where the mask is applied.
db2346
Posts: 16
Joined: 2011-09-29T14:32:10-07:00
Authentication code: 8675308

Re: flattening tiff with layermask on it

Post by db2346 »

OK, I am confused because when I run the convert with te -flatten command in a newer version of IM on a mac, I do not see the noise. why is that?
db2346
Posts: 16
Joined: 2011-09-29T14:32:10-07:00
Authentication code: 8675308

Re: flattening tiff with layermask on it

Post by db2346 »

more confusion, when I bypass the other program, take a photoshop made tif with the OL alpha channel. I then slip out the alpha, thanks for that one, and composite it on top of the image and use lighten to drop out the background and I end up with a simular problem.

not as bad. but it is there.

I used

convert backgroundimage.tif alphamask.tif -compose lighten output.tif

works but still has a halo
http://i.imgur.com/t6dS2.jpg

any clues now? I have been able to "apply" the channel by using
convert background.tif mask.tif +mask output.tif

but i end up with the same problem i am trying to fix, transparent tif.

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

Re: flattening tiff with layermask on it

Post by fmw42 »

OK, so I have a question, can I apply this mask in IM?

i actually have the image without the mask applied. al the mask are named the same, goal is still the same, to have the mask applies with a white back ground. where the mask is applied.
One can apply the mask in IM.

Please provide your underlying image and your alpha channel image as separate images. If they are tiff, you can probably zip them and upload the zip file to most free image hosting servers.

What happens if you create the images as PNG rather than TIFF?

What version of IM are you using? and also what version of libtiff? Are they up to date?
db2346
Posts: 16
Joined: 2011-09-29T14:32:10-07:00
Authentication code: 8675308

Re: flattening tiff with layermask on it

Post by db2346 »

Alright, this is for the searcher out there who might be looking to do this exact thing.

My commands were as followed. not being a IM guru nor a script writer, this might be faster or more concise for someone else, but I cobbled this process together through a lot of trial and error. Not so sure the boss appreciated but i figure I will make it up down the road with other uses of what I have learned.

convert original.tif -channel A -separate +channel -negate original-alpha.tif

convert original.tif original-alpha.tif +clone -compose copy-opacity -composite original_with-trans.tif

convert original_with-trans.tif -flatten original-flatten.tif
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: flattening tiff with layermask on it

Post by fmw42 »

db2346 wrote:Alright, this is for the searcher out there who might be looking to do this exact thing.

My commands were as followed. not being a IM guru nor a script writer, this might be faster or more concise for someone else, but I cobbled this process together through a lot of trial and error. Not so sure the boss appreciated but i figure I will make it up down the road with other uses of what I have learned.

convert original.tif -channel A -separate +channel -negate original-alpha.tif

convert original.tif original-alpha.tif +clone -compose copy-opacity -composite original_with-trans.tif

convert original_with-trans.tif -flatten original-flatten.tif

I am quite confused. Your original had an alpha channel. So you don't need to separate it and then add it back again. My point about separating it was to look at the underlying image which has a broad white jagged outline drawn over your image when IM separates it. I don't know where that is coming from as it does not show up directly in PS.

In principle, all you need to do to flatten the alpha channel is

convert original.tiff -flatten flatten.tif
Post Reply