How to reduce number of the commands lines

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
direction
Posts: 16
Joined: 2019-07-20T21:21:37-07:00
Authentication code: 1152

How to reduce number of the commands lines

Post by direction »

New to imageMacgicK command lines.
Have four commands, want to combine them to one command (or reduce the number as many as possible). The purpose: avoid writing too many output files to disk.
What needed is the maked-final.png file

Code: Select all

convert tmp2.png -background transparent -extent 600x600 mask1.png -composite masked-up.png
composite -compose Dst_Over -geometry +0+350 tmp3.png mask2.png masked-bottom.png
convert masked-bottom.png -fuzz 10% -transparent black masked-bottom-trans.png
convert masked-up.png masked-bottom-trans.png -composite mask3.png -composite masked-final.png
direction
Posts: 16
Joined: 2019-07-20T21:21:37-07:00
Authentication code: 1152

Re: How to reduce number of the commands lines

Post by direction »

The key may be:
How to change the 2nd line: composite command to convert command
direction
Posts: 16
Joined: 2019-07-20T21:21:37-07:00
Authentication code: 1152

Re: How to reduce number of the commands lines

Post by direction »

direction wrote: 2019-08-17T08:14:06-07:00 New to imageMacgicK command lines.
Have four commands, want to combine them to one command (or reduce the number as many as possible). The purpose: avoid writing too many output files to disk.
What needed is the maked-final.png file

Code: Select all

convert tmp2.png -background transparent -extent 600x600 mask1.png -composite masked-up.png
composite -compose Dst_Over -geometry +0+350 tmp3.png mask2.png masked-bottom.png
convert masked-bottom.png -fuzz 10% -transparent black masked-bottom-trans.png
convert masked-up.png masked-bottom-trans.png -composite mask3.png -composite masked-final.png
I have reduced to 2 lines, but not sure how to do it further.

Code: Select all

convert mask3.png tmp3.png -compose Dst_Over -geometry +0+350 -composite -fuzz 10% \
	-transparent black masked-bottom-trans.png
convert tmp2.png -background transparent -extent 600x600 mask1.png -composite \
	masked-bottom-trans.png -composite mask3.png -composite masked-final.png
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to reduce number of the commands lines

Post by fmw42 »

See parenthesis processing https://imagemagick.org/Usage/basics/#parenthesis

Code: Select all

convert tmp2.png -background transparent -extent 600x600 mask1.png -composite \
\( mask3.png tmp3.png -geometry +0+350 -compose Dst_Over -composite \
-fuzz 10% -transparent black \) -composite mask3.png \
-composite masked-final.png
Post Reply