I have successfully used the following command line to create a new GIF image with some simple text
convert -size 100x100 -font arial label:blah output.gif
I would like to achieve the same result using the COM interface from VBScript, but have not been successful in passing in the same parameters in. Here is my code…
Dim img
Set img = CreateObject("ImageMagickObject.MagickImage.1")
Dim fnm(6)
fnm(0) = "-size"
fnm(1) = "100x100"
fnm(2) = "-font"
fnm(3) = "arial"
fnm(4) = "-label"
fnm(5) = "blah"
fnm(6) = "C:\temp\example.gif"
retval = img.convert(fnm)
wscript.echo("retval " & retval)
I execute this code as follows
cscript example.vbs
and the output I get is this, and no GIF file is created…
Microsoft (R) Windows Script Host Version 5.8
Copyright (C) Microsoft Corporation. All rights reserved.
Version: ImageMagick 6.7.4-3 2011-12-24 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2012 ImageMagick Studio LLC
Features: OpenMP
Usage: cscript.exe [options ...] file [ [options ...] file ...] [options ...] file
I’m on Windows7 using ImageMagick-6.7.4-Q16
Does anyone know what I am doing wrong?
[Edit]
In response to Ekkehard’s answer I have also tried not using an array. This code will create an output image, but the label is not applied. I also have to pass in a white image as an input as it will not work without one.
msgs = img.convert("C:\temp\blank.gif", "-size", "100x100", "-font", "arial", "label:", "blah", "C:\temp\example.gif")
In the end I gave up trying to get
labelto work when using the COM+ API and have a solution that uses-drawinstead. Ekkehard was right about not using an Array, and instead use individual arguments as shown below.