Page 1 of 1

-fx and -channel

Posted: 2017-09-30T10:14:01-07:00
by Ariel
Hello.
Why result of:

Code: Select all

convert 1.png 2.png -channel r -fx "v.r" -channel g -fx "v.g" -channel b -fx "v.b" 3.png
is not looks like 2.png?
In "3.png" red channel - red channel of "2.png", but
In "3.png" green and blue channel - green and blue channel channel of "1.png"!
Please help.Thanks.

Re: -fx and -channel

Posted: 2017-09-30T10:38:22-07:00
by snibgo
Each "-fx" is an operator that replaces all the images in the current list with a result.

So the first "-fx" replaces both your inputs with a single image. The other "-fx" operators have only one input.

Re: -fx and -channel

Posted: 2017-09-30T10:52:46-07:00
by Ariel
Thank you.
I will use:

Code: Select all

convert 1.png 2.png -channel r -fx "v.r" 2.png -channel g -fx "v.g" 2.png -channel b -fx "v.b" 3.png
Or there is a more correct solution for separate processing channels for two images?

Re: -fx and -channel

Posted: 2017-09-30T11:18:43-07:00
by snibgo
You command reads the 2.png file three times. There are many ways to read it only once. For example:

Code: Select all

convert 1.png 2.png +write mpr:NUM2 -channel r -fx "v.r" mpr:NUM2 -channel g -fx "v.g" mpr:NUM2 -channel b -fx "v.b" 3.png

Re: -fx and -channel

Posted: 2017-09-30T13:23:42-07:00
by Ariel
Thank you. Unfortunately the last option works incorrectly - it sees only red channel from second image too.

Re: -fx and -channel

Posted: 2017-09-30T13:36:23-07:00
by Ariel

Code: Select all

convert 2.png +write mpr:N2 +delete 1.png mpr:N2 -channel r -fx "v.r" mpr:N2 -channel g -fx "v.g" mpr:N2 -channel b -fx "v.b" 3.png
Now works! tnx.

Re: -fx and -channel

Posted: 2017-10-01T11:39:49-07:00
by fmw42
I am not sure -fx is channel sensitive (-channel). Operations on the channels is done with the suffix .r, .g, .b on u or v. So I suspect that -channel can be removed.