Swizzling channels seems to be unreasonable difficult to do with the commands available.
Here's what I've tried so far:
convert -channel BA -fill '#000000FF' <- doesn't seem to do anything or produce a warning, I still see blue in the final image
convert -channel-fx 'red, red, red, white' <- despite docs, white, 0, 1, 255, 0xFF isn't accepted
This is the only thing that kind of works, but I'm still at a loss for why I can't just fill a channel to 0 or 1 with channel-fx
convert -channel-fx 'red=>green red=>blue' <- tried to add white=>alpha here
The convert command line really needs a simple swizzle command (command 238) using r,g,b,a,i,0,1,#FF or #FFFF for a number.
convert -swizzle rgb1
convert -swizzle rg01
convert -swizzle rrrr1
convert -swizzle gggr
Swizzling Data
Re: Swizzling Data
This works and avoids the channel mask and fill. Be careful not to use commas or that will assign to the respective channels.
convert -channel-fx 'red=>green red=>blue alpha=100%' # rrr1
convert -channel-fx 'red=>green red=>blue alpha=100%' # rrr1
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Swizzling Data
In IM 6, you can do your rrr1 by:
By default, alpha is fully opaque (alpha=1).
If you want rrr0, you can do
You can do rg01 by:
IM 6 does not have -channel-fx. That is only in IM 7. See http://imagemagick.org/script/porting.php#cli
Code: Select all
convert image.png -channel r -separate +channel -duplicate 2 -set colorspace sRGB -combine PNG32:image_rrr1.png
If you want rrr0, you can do
Code: Select all
convert image.png -channel r -separate +channel -duplicate 2 -set colorspace sRGB -combine -alpha transparent PNG32:image_rrr0.png
You can do rg01 by:
Code: Select all
convert image.png -channel b -evaluate set 0 +channel PNG32:image_rg01.png