Hi,
It's hard to believe this software is seldom used in the VB/.NET world, but there are almost no examples or documentation anywhere to be found. I'm putting this here for anyone else to find in future searches. As you'll see I'm not an accomplished VB coder but it works.
I got the basic concept of a parameter array from this post,
viewtopic.php?f=8&t=18140,but could not get any output when trying to feed in file names and parameters from a text file containing the commands I wanted to execute.
Here is how I was able to use variable parameters with the ImageMagick COM object image.convert()
I put all the ImageMagick parameters in a single line string (read from a text file) including the input and output file names as the first and last values, e.g.
Code: Select all
Dim sCommand As String
sCommand = "c:\inputfile.tif,-strip,-density,96,-profile,USWebCoatedSWOP.icc,-profile,sRGB_v4_ICC_preference.icc,-quality,100,-resize,680x680^,c:\outputfile.jpg"
Split the string into an array,
Code: Select all
Dim iParams(1) As Object
iParams = sCommand.Split(",")
At this point I though that
would work but it didn't, and eventually I saw the error "specified array was not of the expected type". Seems the split command messed up the array, so I copied the values into a new array:
Code: Select all
Dim sParams(1) As Object
Dim cNum As Integer
Dim i As Integer
cNum = iParams.Length
ReDim sParams(cNum)
For i = 0 To cNum - 1
sParams(i) = iParams(i)
Next
myImg.convert(sParams)
WORKS!