Command combination conflict, why? [SOLVED]

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?".
Post Reply
weblife
Posts: 21
Joined: 2016-01-06T22:23:33-07:00
Authentication code: 1151

Command combination conflict, why? [SOLVED]

Post by weblife »

Hello,

I get all kinds of alpha issue with the layers after i combine four commands. Ran individually they output correctly but when combined I get the issue at hand.

I am using ImageMagick 6.9.1-10 Q16 x86_64 2015-07-26 in Term2 on OSX El Capitan.

Individual Commands:

Code: Select all

// Steps needed
convert \( -size 2000x2000 xc:white null: \( large.jpg -coalesce \) -gravity Center -layers Composite alphaL.png -compose copy_opacity -gravity Center -composite \) large_cut.png

convert \( -size 2000x2000 xc:white null: \( medium.jpg -coalesce \) -gravity Center -layers Composite alphaM.png -compose copy_opacity -gravity Center -resize 79.72% -composite \) medium_cut.png

convert \( -size 2000x2000 xc:white null: \( small.jpg -coalesce \) -gravity Center -layers Composite alphaS.png -compose copy_opacity -gravity Center -resize 64.12% -composite \) small_cut.png

convert -size 2000x2000 xc:white null: \( large_cut.png -coalesce \) -gravity center -layers Composite -layers Optimize null: \( medium_cut.png -coalesce \) -gravity center -layers Composite -layers Optimize null: \( small_cut.png  -coalesce \) -gravity center -layers Composite -layers Optimize final.png
Concatenated Commands:

Code: Select all

convert \
\( -size 2000x2000 xc:white null: \( large.jpg -coalesce \) -gravity Center -layers Composite alphaL.png -compose copy_opacity -gravity Center -composite \) \
\( -size 2000x2000 xc:white null: \( medium.jpg -coalesce \) -gravity Center -layers Composite alphaM.png -compose copy_opacity -gravity Center -resize 79.72% -composite \) \
\( -size 2000x2000 xc:white null: \( small.jpg -coalesce \) -gravity Center -layers Composite alphaS.png -compose copy_opacity -gravity Center -resize 64.12% -composite \) \
-size 2000x2000 xc:white null: \( -clone 0 -coalesce \) -gravity center -layers Composite -layers Optimize null: \( -clone 1 -coalesce \) -gravity center -layers Composite -layers Optimize null: \( -clone 2 -coalesce \) -gravity center -layers Composite -layers Optimize -composite final.png
Last edited by weblife on 2016-02-22T11:40:08-07:00, edited 1 time in total.
User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: Command combination conflict, why?

Post by GeeMack »

weblife wrote:I get all kinds of alpha issue with the layers after i combine four commands. Ran individually they output correctly but when combined I get the issue at hand.
Without running tests, and just from looking over the commands, I'd suspect your "-compose" operators are causing the problem. If you reset them with "+compose" after you apply each "-composite", you'll return to the default compose method. As it is you're carrying the "-compose copy_opacity" into each next part of the combined command, where with the individual commands, you're starting with a default "-compose" setting.
sergpush
Posts: 1
Joined: 2016-02-15T17:27:24-07:00
Authentication code: 1151

Re: Command combination conflict, why?

Post by sergpush »

weblife, did you fix the issue?
DJI Mavic Pro is one of the best drone out there. Here is Mavic Pro vs DJI Spark review.
weblife
Posts: 21
Joined: 2016-01-06T22:23:33-07:00
Authentication code: 1151

Re: Command combination conflict, why?

Post by weblife »

@sergpush Apologize for the delay in response, went away for the weekend. Thank you for your rapid response. I gave your suggestion a try and it resolved the alpha transparency issue I was having. The layers still aren't being processed correctly, but at least one problem solved.
weblife
Posts: 21
Joined: 2016-01-06T22:23:33-07:00
Authentication code: 1151

Re: Command combination conflict, why? [SOLVED]

Post by weblife »

It came down to the order of operations along with a few other things but in the end this command worked:

Code: Select all

convert \
\( xc:white[2000x2000\!] \) \
\( -clone 0 null: \( large.jpg -coalesce \) -gravity Center -layers Composite -layers Optimize \) \
\( -clone 0 null: \( medium.jpg -coalesce \) -gravity Center -layers Composite -layers Optimize \) \
\( -clone 0 null: \( small.jpg -coalesce \) -gravity Center -layers Composite -layers Optimize \) \
\( -clone 1 alphaL.png -compose copy_opacity -gravity Center -composite +compose \) \
\( -clone 2 alphaM.png -compose copy_opacity -gravity Center -resize 79.72% -composite +compose \) \
\( -clone 3 alphaS.png -compose copy_opacity -gravity Center -resize 64.12% -composite +compose \) \
-delete 0-3 \
\( -clone 0-1 -gravity center -compose src-over -composite \) \
\( -clone 3-2 -gravity center -compose src-over -composite \) \
-delete 0-3 final.png
Post Reply