Does anyone have a working example of using the ImageMagick Object? What is in the database no longer seems to work...at least for me. I have tried numerous variations of the following. I currently get OLE Exception. Depending on what I try I get more specific errors so reasonably sure the object is installed correctly and the problem isn't on that front.
Jim
objIM = ObjectCreate("ImageMagickObject.MagickImage")
ofile ="decking.jpg:"
msgs = objIM.Identify("NULL:",ofile,"-format","%%m,%%h,%%w")
Message("Msg",msgs)
ObjectClose(objIM)
objIM = 0
I assume one of your variations was CreateObject("ImageMagickObject.MagickImage.1")
Yes.
Looking at the "Identify" method in the WIL Type Viewer, the method has one parameter. It is an array of references to variants. I assume this means that the array elements represent switches that are used with the "Identify" CLI command. Is there any COM or dotNet documentation around?
Haven't found it but that means little. What little it says on the web site states that one can usually copy the parameter values from the command line directly into the COM object Method and it should work. I will keep looking. Happy to see an example of Convert that would work as well just to know that something works. I tried those from the database but no luck. Thanks.
Jim
I do appreciate you mentioning the Type Viewer. I should have thought of that.
Jim
Here is an autoit example that supposedly works and was recently posted to a forum.
$ImageMagick = ObjCreate("ImageMagickObject.MagickImage.1")
$test = $ImageMagick.identify("-verbose", "10499370_267852580088660_4278776929494865645_o_2.jpg")
Jim
Here is the documentation I have found...
The ImageMagickObject COM+ component provides access to the compare, convert, composite, mogrify, identify, montage, and stream tools, efficiently executing them as part of your process, rather than as external programs. The way you use it is exactly the same. You pass it a list of strings including filenames and various options and it does the job. In fact, you can take any existing batch scripts that use the command line tools and translate them into the equivalent calls to the COM+ object in a matter of minutes. Beyond that, there is also a way to pass in and retrieve images in memory in the form of standard smart arrays (byte arrays). Samples are provided, to show both the simple and more elaborate forms of access.
Quote from: JTaylor on November 26, 2019, 09:34:45 AM
Here is an autoit example that supposedly works and was recently posted to a forum.
$ImageMagick = ObjCreate("ImageMagickObject.MagickImage.1")
$test = $ImageMagick.identify("-verbose", "10499370_267852580088660_4278776929494865645_o_2.jpg")
Jim
Changed the image name to a jpg on the system and modified the syntax to match the language. The script did not work with cscript (vbs), wscript (vbs), nor WinBatch.
Got this to work. See comment.
objIm = CreateObject("ImageMagickObject.MagickImage.1")
;; Because the ImageMagick type library is [b]completely wrong[/b] you need
;; to tell WIL to ignore it by giving the first parameter a variant type.
msgs = objIm.Convert(bstr:'-verbose', 'C:/Temp/Tests/116_1611.bmp', '116_1611.jpg')
Thank you VERY much!!! I had played around with ObjectType but hadn't quite gotten the right combination.
Probably want to update all the database entries related to ImageMagickObject.
Thanks again and have a Happy Thanksgiving.
Jim
ImageMagick is notoriously buggy and attempting to keep up with what does or does not work from version to version is not worth the time. The only change that might be considered would be to remove any references to the product in the Tech Database.
Works for me :)
Jim
Until it doesn't.
I meant about you removing stuff.
Jim
My error.
Maybe a final note on the subject of ImageMagick. There is a dotNet assembly for ImageMagick on Github. I haven't tried it so I can't attest to its quality or usability in WIL but it might be a viable alternative to COM Automation when attempting to use 7.x versions of ImageMagick.
Thanks. Will take a look.
Jim
Jim;
I don't use ImageMagic but glad to help out with any CLR code.