Join Commands.
Join Commands.
I have this command's:
composite -compose Multiply "b.png" "p4.png" "p0.png"
composite -compose Multiply "y.png" -negate "p4.png" "p1.png"
composite -compose Plus "p0.png" "p1.png" "final.png"
used one after one it generates my needed image, but I only need final.png. p0,p1 are not needed. How to join into one line these commands ?
I tried:
convert "b.png" "y.png" "p4.png" \
\( -clone 2 -negate \) \
\( -clone 0,2 -compose Multiply \) \
\( -clone 1,3 -compose Multiply \) \
\( -clone 4,5 -compose Plus \) \
\final.png
I use:
ImageMagick 6.8.9-9 Q16 x86_64 2018-09-28
composite -compose Multiply "b.png" "p4.png" "p0.png"
composite -compose Multiply "y.png" -negate "p4.png" "p1.png"
composite -compose Plus "p0.png" "p1.png" "final.png"
used one after one it generates my needed image, but I only need final.png. p0,p1 are not needed. How to join into one line these commands ?
I tried:
convert "b.png" "y.png" "p4.png" \
\( -clone 2 -negate \) \
\( -clone 0,2 -compose Multiply \) \
\( -clone 1,3 -compose Multiply \) \
\( -clone 4,5 -compose Plus \) \
\final.png
I use:
ImageMagick 6.8.9-9 Q16 x86_64 2018-09-28
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Join Commands.
Reverse the order of your pairs of images when using convert. See https://imagemagick.org/Usage/compose/#compose. Also why is there a \ before final.png?
If that does not help, then post your images to some free hosting service that won't change the format and put the URLs here.
If that does not help, then post your images to some free hosting service that won't change the format and put the URLs here.
Re: Join Commands.
https://i.ibb.co/Wc0P92h/B.png <- B image
https://i.ibb.co/JvYYkw6/Y.png <- Y image
https://i.ibb.co/2t0M5t0/p4.png <- p4 image (grayscale mask)
https://i.ibb.co/NTz7jkr/final.png <- Wanted Result
I tried changing the order and removed before final "/", but I don't know if I understood it right:
convert "b.png" "y.png" "p4.png" \
\( -clone 2 -negate \) \
\( -clone 2,0 -compose Multiply \) \
\( -clone 3,1 -compose Multiply \) \
\( -clone 5,4 -compose Plus \) \
final.png
but i get error :"(: command not found" on ubuntu
https://i.ibb.co/JvYYkw6/Y.png <- Y image
https://i.ibb.co/2t0M5t0/p4.png <- p4 image (grayscale mask)
https://i.ibb.co/NTz7jkr/final.png <- Wanted Result
I tried changing the order and removed before final "/", but I don't know if I understood it right:
convert "b.png" "y.png" "p4.png" \
\( -clone 2 -negate \) \
\( -clone 2,0 -compose Multiply \) \
\( -clone 3,1 -compose Multiply \) \
\( -clone 5,4 -compose Plus \) \
final.png
but i get error :"(: command not found" on ubuntu
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Join Commands.
The \ character means "the command continues on the next line" only when it is the final character of the line. Don't have a space after it.
snibgo's IM pages: im.snibgo.com
Re: Join Commands.
there is no more error with "\", thanks.
but it produces 9 images(final33-0 to 9) and none of them is like my wanted result. what can I do now ?
but it produces 9 images(final33-0 to 9) and none of them is like my wanted result. what can I do now ?
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Join Commands.
"-compose X" is a setting that is used by some operators such as "-composite". So replace "-compose Multiply" with "-compose Multiply -composite", etc.
snibgo's IM pages: im.snibgo.com
Re: Join Commands.
thanks, now it works 100%! Great Forum!
convert "b.png" "y.png" "p4.png" \
\( -clone 2 -negate \) \
\( -clone 0,2 -compose Multiply -composite \) \
\( -clone 1,3 -compose Multiply -composite \) \
\( -clone 4,5 -compose Plus -composite \) \
-delete 0-5 final99.png
convert "b.png" "y.png" "p4.png" \
\( -clone 2 -negate \) \
\( -clone 0,2 -compose Multiply -composite \) \
\( -clone 1,3 -compose Multiply -composite \) \
\( -clone 4,5 -compose Plus -composite \) \
-delete 0-5 final99.png
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Join Commands.
try this
Code: Select all
convert b.png p4.png \
\( -clone 0,1 -compose multiply -composite \) \
\( y.png -negate -clone 1 -compose multiply -composite \) \
-delete 0,1 \
-compose plus -composite \
final.png
Re: Join Commands.
thanks fmw42, for Your reply, but this is not using "y.png"(Yellow). I mean the result is only black and blue.
https://i.ibb.co/r3W0f1f/final4.png
For now I have:
convert "b.png" "y.png" "p4.png" \
\( -clone 2 -negate \) \
\( -clone 0,2 -compose Multiply -composite \) \
\( -clone 1,3 -compose Multiply -composite \) \
\( -clone 4,5 -compose Plus -composite \) \
\( -clone 6,0 -compose CopyOpacity -composite \) \#I also needed to add this line because it happens that the alpha channel went everywhere 255, what was not intended.
-delete 0-6 final88.png
If there is an more elegant solution fmw42 please let me know.
https://i.ibb.co/r3W0f1f/final4.png
For now I have:
convert "b.png" "y.png" "p4.png" \
\( -clone 2 -negate \) \
\( -clone 0,2 -compose Multiply -composite \) \
\( -clone 1,3 -compose Multiply -composite \) \
\( -clone 4,5 -compose Plus -composite \) \
\( -clone 6,0 -compose CopyOpacity -composite \) \#I also needed to add this line because it happens that the alpha channel went everywhere 255, what was not intended.
-delete 0-6 final88.png
If there is an more elegant solution fmw42 please let me know.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Join Commands.
See my line
But my code was not tested. So I could have made a mistake. Your code should be able to reduce the number of images you keep around in memory.
Code: Select all
\( y.png -negate -clone 1 -compose multiply -composite \) \
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Join Commands.
This seems to work for me to reproduce your final image.
Code: Select all
convert p4.png \
\( -clone 0 b.png -compose multiply -composite +write fred_p0.png \) \
\( -clone 0 -negate y.png -compose multiply -composite +write fred_p1.png \) \
-delete 0 \
-compose plus -composite \
fred_final.png
Re: Join Commands.
Yes this new ones works, thanks. so which one should I use in my application? which one is better? I mean Yours produce two more images, but deletes only 1, mine produces only one final. so i is my better?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Join Commands.
I forgot to remove the extra writes that I used for testing. Use the following:
Code: Select all
convert p4.png \
\( -clone 0 b.png -compose multiply -composite \) \
\( -clone 0 -negate y.png -compose multiply -composite \) \
-delete 0 \
-compose plus -composite \
final.png