[plt-scheme] MysterX and ImageMagick COM object

From: Anton van Straaten (anton at appsolutions.com)
Date: Wed Jul 23 17:19:24 EDT 2003

> > In DrScheme I try
> >   (define im (cci/progid "ImageMagickObject.MagickImage"))
> >   (com-invoke im "Convert" "C:\\arf.bmp" "C:\\arf.jpg")
> >
> >   com-invoke (method "Convert"): expects type <com-0x401b> as 3rd
> >   argument, given: "C:\\arf.bmp"; other arguments were: #<com-object>
> >   "Convert"a "C:\\arf.jpg"
> >
> > 0x401b is a VT_SAFEARRAY, so I guess I need to know how, if
> > possible, to create that in DrScheme.
> I believe you need to create a vector, although I'm not sure
> of its contents.

I think the problem is more with MysterX's argument type checking than
anything else.  Here's the IDL for the function in question (many of the
other ImageMagick functions have a similar signature):

 [id(0x00000004), vararg]
   HRESULT Convert([in, out] SAFEARRAY(VARIANT)* pArrayVar,
                   [out, retval] VARIANT* pVar);

Drawing on rusty memories of COM from a prior life, with a vararg function,
despite the look of the above signature, the variable number of arguments
are simply copied into the rgvarg array like normal arguments, as though the
function were defined as Convert(VARIANT* p1, VARIANT* p2, ...).  Wrapping
in vectors won't work, because the arguments aren't expected to be wrapped
in that way.

Given an expression like (com-invoke im "Convert" p1 p2 ...), MysterX's
buildMethodArgumentsUsingFuncDesc probably already either does or almost
does the right thing, as long as it's driven by the number of supplied
arguments, rather than the number of arguments specified in the signature.

But it looks as though the problem is occurring earlier, in the loop at the
end of checkArgTypesAndCounts, which appears not to understand vararg
functions.  Fixing this - as well as making sure that
argsCount->numParamsPassed is set to the actual number of provided args when
a varargs function is involved - would probably fix the problem.

I would try a quick hack to test or fix it myself, but MysterX doesn't seem
to compile with VC6 any more, and installing VC7 is way down on my priority

> Is it possible to get a copy of the ImageMagick COM server?

It's contained in the ImageMagick Windows binary distribution, e.g.:
You have to check a box for it when installing.

Other ImageMagick download sites are here:

BTW, I noticed an MzScheme v103 extension for ImageMagick here:
Has anyone looked at upgrading that to 204?


Posted on the users mailing list.