Page 1 of 1

Consolidating Commands

Posted: 2014-03-13T12:16:23-07:00
by dmfelder
Hello All! I have a project that requires me to perform 5 different commands, but I'm wondering if they can be consolidated because the process takes a while.

I am taking one image (myimagename1), merging the layers and creating a new image (myimagename). Then I am changing the size of the image. Then I am merging the image with a background image. Then I'm resizing it. Then I'm stripping it. Here are my commands:

Code: Select all

Convert "-background", "none", "-layers", "merge", myimagename1, myimagename
                               
Convert "-thumbnail", "2000x4000", "-bordercolor", "none", "-border", "0", myimagename, myimagename
                          
Convert "-composite", mybackground, myimagename, "-geometry", "+500+200", myimagename

Convert myimagename, "-resize", "1000x1000", myimagename
                                   
Convert myimagename, "-strip", myimagename
Is there a way to combine some of these commands?

Again, it works, but it takes a while to complete.

THANKS!
-David

Re: Consolidating Commands

Posted: 2014-03-13T13:06:59-07:00
by fmw42
In unix, try

Code: Select all

convert myimagename1 \
-background none -flatten \
-thumbnail 2000x4000 \
-bordercolor none -border 0 \
mybackground +swap -geometry +500+200 -composite \
-resize 1000x1000 -strip \
myimagename
or windows I believe it would just be

Code: Select all

convert myimagename1 ^
-background none -flatten ^
-thumbnail 2000x4000 ^
-bordercolor none -border 0 \
mybackground +swap -geometry +500+200 -composite ^
-resize 1000x1000 -strip ^
myimagename
I am not sure why you are adding -bordercolor none -border 0. It adds zero border and seems like a no-op situation to me. You have already specified to flatten the image with transparent background. I have used the simpler -flatten rather than -layers merge. Also -thumbnail and -resize do the same thing, except -thumbnail has a built in -strip.

Note that proper IM syntax has you read a raster image before applying any operations to it.

The use of \ in unix and ^ in windows at the end of a line, allows you to write commands on multiple lines for more readability. In the above cases, you can remove all of them if you do not write to more than one line of text.

Re: Consolidating Commands

Posted: 2014-03-13T14:02:57-07:00
by dmfelder
OMG! Wonderful. It takes about 75% less time!!!

You guys are great!

Re: Consolidating Commands

Posted: 2014-03-13T14:44:37-07:00
by fmw42
try removing the -bordercolor none -border 0 and see if that helps and keeps the same output