ImageMagick Object

Started by JTaylor, November 25, 2019, 03:12:04 PM

Previous topic - Next topic

JTaylor

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

Code (winbatch) Select

objIM = ObjectCreate("ImageMagickObject.MagickImage")

ofile ="decking.jpg:"

msgs = objIM.Identify("NULL:",ofile,"-format","%%m,%%h,%%w")

Message("Msg",msgs)

ObjectClose(objIM)
objIM = 0



stanl

I assume one of your variations was CreateObject("ImageMagickObject.MagickImage.1")

JTaylor


td

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?
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

JTaylor

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

JTaylor

I do appreciate you mentioning the Type Viewer.   I should have thought of that.

Jim

JTaylor

Here is an autoit example that supposedly works and was recently posted to a forum.

Code (winbatch) Select

$ImageMagick = ObjCreate("ImageMagickObject.MagickImage.1")
$test = $ImageMagick.identify("-verbose", "10499370_267852580088660_4278776929494865645_o_2.jpg")




Jim

JTaylor

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.

td

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.

Code (winbatch) Select

$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.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

td

Got this to work.  See comment.

Code (winbatch) Select
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')
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

JTaylor

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

td

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.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

JTaylor


td

"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

JTaylor

I meant about you removing stuff.

Jim

td

"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

td

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. 
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

JTaylor

Thanks.   Will take a look.

Jim

stanl

Jim;


I don't use ImageMagic but glad to help out with any CLR code.