Page 1 of 1

VBS: How to use Parenthesis to isolate affects of operators

Posted: 2012-11-21T11:18:20-07:00
by cativo
Using parenthesis, \(Image1.jpg image2.jpg -operator1 -operator2\) to isolate the affect of operators to just specific image lists is explained here http://www.imagemagick.org/Usage/basics/#parenthesis. The parenthesis are escaped by "\' for unix, but for DOS it is not required.

How do you do this in VBS?

I tried enclosing enclosing everything in quotes separated by commas, including the "(" and ")", but it doesn't seem to work. For example:

Code: Select all

objImageMagick_01.Convert "-background", "none", "-fill", "white", "-font", "Arial", "-pointsize", "90", "label:test", "(","+clone","-background","red","-shadow","200x3+0+0",")","+swap","-background","none","-layers","merge","+repage", "c:\test.png"
Any ideas?

Re: VBS: How to use Parenthesis to isolate affects of operat

Posted: 2012-11-21T11:23:28-07:00
by fmw42
Be sure to leave a space around each ( and )

I am not a windows or vbs user, so this may be special to vbs, but IM command lines do not include commas between settings or options.

Re: VBS: How to use Parenthesis to isolate affects of operat

Posted: 2012-11-21T15:15:54-07:00
by cativo
Thanks, but I don't think that fixed the problem. I beleive it is crucial to have the spaces for DOS scripting, not sure about VBS.

I actually found my problem. The parenthesis were located in the wrong positions, so the operators were being isolated incorreclty, yielding a different result.

Just for reference, here is a DOS and VBS equivalent that give the same result, in case anyone is having the same problem.

This script takes imageIn.jpg and applies a clut (Color Look Up Table) to colorize it, but before doing so, shifts only the clut image lut.jpg 100 pixels vertically. Without the parenthesis, the -roll operation would occur on both the imageIn.jpg and the lut.jpg images.

DOS example:

Code: Select all

convert imageIn.jpg ( lut.jpg -roll +0+100 ) -clut imageOut.jpg
Make sure there are spaces on each side of the parenthesis.

VBS example:

Code: Select all

set image = CreateObject("ImageMagickObject.MagickImage.1")
image.convert "imageIn.jpg", "(", "lut.jpg", "-roll", "+0+100", ")", "-clut", "imageOut.jpg"