Page 1 of 1

DLL call in AutoIt scripting language

Posted: 2007-10-16T15:44:37-07:00
by miky2003
Hello all-
THANKS for the awesome tool that ImageMagick is, and everyone who contributes to the 'community' support...

I'm using a scripting language called AutoIt (http://autoitscript.com) that has COM support, but I'm fairly new to the concept of calling DLLs. I've got the static ImageMagickObject.dll (the one that doesn't ask me for all the other dlls when I call it), and I'm trying to do a basic Convert command using it.

I think I understand that I should be able to call the convert function from the dll, but I think I'm getting something wrong or I don't know what I'm doing even more than I realize :? (and before we get into it, yes, I realize the licencing requirements I'm getting into by calling the dlls directly in a compiled script, and I intend to adhere to them).

Here's the syntax in AutoIt for calling a function from a dll:

Code: Select all

DllCall ( "dll", "return type", "function" [, "type1", param1 [, "type n", param n]] )
So here's what I've got in my script:

Code: Select all

DLLCall("ImageMagickObject.dll","int","convert","str",@ScriptDir&"\us.jpg","str",@ScriptDir&"\us.gif")
after I run this line, I'm getting an error value of 3, which means that the function was not found in the dll file. I'd assumed that convert would be the function I needed...but apparently not, and I can't find a list of all the functions' names in the dll file either, so I'm a bit stuck.

I'm going to be using this script on computers that don't have IM installed, so I don't think the answer is using straight COM, unless I'm supposed to register the dll using regsrv32, then create a new IM object, then unregister the dll...does that sound more along the lines I should be pursuing?

Thanks for any attempts to help me...I know it's not very fair to ask for help with a language that you don't know, but I was hoping that by posting here, someone with a bit of knowledge of the structure of the ImageMagickObject.dll might be able to pick up on what I'm doing wrong...I appreciate the time I've taken from you :D

Re: DLL call in AutoIt scripting language

Posted: 2007-10-18T09:10:38-07:00
by miky2003
Got it resolved. I did have the completely wrong idea about dlls after all...I didn't know that CALLING a function in a dll directly is different than COM. ImageMagickObject.dll, as it says, is a COM+ server dll, which means it has to be registered, then you make ImageMagickObject.MagickImage objects, and transform the object from there. In AutoIt, this looks like:

Code: Select all

FileInstall("ImageMagickObject.dll",@SystemDir&"\ImageMagickObject.dll",0)
RunWait(@ComSpec & " /c regsvr32 /s ImageMagickObject.dll",@SystemDir,@SW_HIDE)
$oIM=ObjCreate("ImageMagickObject.MagickImage")
$oIM.Convert("sample.jpg", "-resize","150x150", "-sepia-tone","80%", "sampleThumb.jpg")
Thanks anyway! 8)