WinBatch Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: JTaylor on November 25, 2019, 03:12:04 pm

Title: ImageMagick Object
Post by: JTaylor on November 25, 2019, 03:12:04 pm
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
objIM = ObjectCreate("ImageMagickObject.MagickImage")

ofile ="decking.jpg:"

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

Message("Msg",msgs)

ObjectClose(objIM)
objIM = 0


 
Title: Re: ImageMagick Object
Post by: stanl on November 26, 2019, 02:27:45 am
I assume one of your variations was CreateObject("ImageMagickObject.MagickImage.1")
Title: Re: ImageMagick Object
Post by: JTaylor on November 26, 2019, 06:37:30 am
Yes.
Title: Re: ImageMagick Object
Post by: td on November 26, 2019, 09:03:00 am
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?
Title: Re: ImageMagick Object
Post by: JTaylor on November 26, 2019, 09:10:57 am
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
Title: Re: ImageMagick Object
Post by: JTaylor on November 26, 2019, 09:28:25 am
I do appreciate you mentioning the Type Viewer.   I should have thought of that.

Jim
Title: Re: ImageMagick Object
Post by: 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
$ImageMagick = ObjCreate("ImageMagickObject.MagickImage.1")
$test = $ImageMagick.identify("-verbose", "10499370_267852580088660_4278776929494865645_o_2.jpg")
 



Jim
Title: Re: ImageMagick Object
Post by: JTaylor on November 26, 2019, 09:38:53 am
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.
Title: Re: ImageMagick Object
Post by: td on November 26, 2019, 10:12:36 am
Here is an autoit example that supposedly works and was recently posted to a forum.

Code: Winbatch
$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.
Title: Re: ImageMagick Object
Post by: td on November 26, 2019, 02:34:45 pm
Got this to work.  See comment.

Code: Winbatch
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')
Title: Re: ImageMagick Object
Post by: JTaylor on November 26, 2019, 02:54:01 pm
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
Title: Re: ImageMagick Object
Post by: td on November 26, 2019, 07:17:28 pm
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.
Title: Re: ImageMagick Object
Post by: JTaylor on November 26, 2019, 08:01:15 pm
Works for me  :)

Jim
Title: Re: ImageMagick Object
Post by: td on November 27, 2019, 07:43:12 am
Until it doesn't.
Title: Re: ImageMagick Object
Post by: JTaylor on November 27, 2019, 09:59:02 am
I meant about you removing stuff.

Jim
Title: Re: ImageMagick Object
Post by: td on November 27, 2019, 10:37:09 am
My error.
Title: Re: ImageMagick Object
Post by: td on December 05, 2019, 07:31:29 am
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. 
Title: Re: ImageMagick Object
Post by: JTaylor on December 05, 2019, 07:52:45 am
Thanks.   Will take a look.

Jim
Title: Re: ImageMagick Object
Post by: stanl on December 08, 2019, 11:50:49 am
Jim;


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