Hi,
I have a series of png images with transparency that I would like to have a montage of. The thing is, I only want the alpha channel, and AS an alpha channel. The rest of channels (R,G and B) can be any solid color.
The way I have come so far is to do it in three steps.
First I mount the series as a grayscale of the alpha:
montage -alpha Extract [series...] alpha_grayscale.png
Then I create an empty canvas, solid color:
convert -size [w and h of my spritsheet] canvas:red canvas.png
And then I push the alpha in that solid image:
convert canvas.png alpha_grayscale.png +matte -compose CopyOpacity -composite PNG32:alpha.png
What I want to know is if it is possible to do all that in a single montage command.
I've played with the -compose option a little bit, but I did not succeed. In fact it is unclear to me what the options in the montage command apply to. If I want to do a png with image as well as alpha (so 32 bits), I have to set -background none, otherwise there won't be any transparency in the montage. Like so:
montage -alpha Set -background none [series...] PNG32:montage_with_alpha.png
The -background option seems to apply to the canvas that's created for the spritesheet. But then, in my specific case, I want a solid color canvas with a transparency channel, so what do I do?
I also thought that the -channel options would let me choose which channels I want to use and copy in the final composition, but it does not seem to do that. In fact, from the documentation, I never understood what the channel option does. It says that it determines what channels the subsequent operation apply to, but what these subsequent operations might be eludes me.
Thank you for your help!
Creating a montage of only the alpha channel
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Creating a montage of only the alpha channel
No, there is no convert equivalent of montage. So you need to pipe the result from montage to convert.
try the following with your original color images with their alpha channels:
montage ... image1 image2 ... imageN miff:- | convert - alpha off -fill red -colorize 100% -alpha on resultimage
see
http://www.imagemagick.org/Usage/masking/#alpha
http://www.imagemagick.org/Usage/color_mods/#colorize
What version of IM are you using and what platform. The above may not work if not a current enough IM.
try the following with your original color images with their alpha channels:
montage ... image1 image2 ... imageN miff:- | convert - alpha off -fill red -colorize 100% -alpha on resultimage
see
http://www.imagemagick.org/Usage/masking/#alpha
http://www.imagemagick.org/Usage/color_mods/#colorize
What version of IM are you using and what platform. The above may not work if not a current enough IM.
Re: Creating a montage of only the alpha channel
Thanks, It's what I was looking for. I did not know that you could pipe IM commands with intermediary images that do not get written to disk.
I use version 6.6.9-7, so the syntax that you provided did not work, but me and my friend Google found a syntax that works for my version, which is
convert <(montage -background none -alpha Set -geometry +0+0 file1.png, file2.png... miff:-) -alpha off -fill red -colorize 100% -alpha on PNG32:filename.png;
Well, thanks again. If you were in Hogwarts, I'd give 10 points to your house.
I use version 6.6.9-7, so the syntax that you provided did not work, but me and my friend Google found a syntax that works for my version, which is
convert <(montage -background none -alpha Set -geometry +0+0 file1.png, file2.png... miff:-) -alpha off -fill red -colorize 100% -alpha on PNG32:filename.png;
Well, thanks again. If you were in Hogwarts, I'd give 10 points to your house.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Creating a montage of only the alpha channel
I do not understand the <.convert <(montage -background none -alpha Set -geometry +0+0 file1.png, file2.png... miff:-) -alpha off -fill red -colorize 100% -alpha on PNG32:filename.png;
In unix, this should work with $
convert $(montage -background none -alpha Set -geometry +0+0 file1.png, file2.png... miff:-) -alpha off -fill red -colorize 100% -alpha on PNG32:filename.png;