Page 1 of 1

Method 'Convert' of object 'IMagickImage' failed

Posted: 2009-03-24T10:46:00-07:00
by rgoodson40
Hello,

I am attempting to convert a pdf file to a tif file using ImageMagick from within a VB6 application. Everytime I try it, however, I get the following error message: Method 'Convert' of object 'IMagickImage' failed.

My code is as follows:

Code: Select all

Dim InputFile As Variant
Dim OutputFile As Variant
Dim imo As ImageMagickObject.MagickImage
    
InputFile = "C:\input.pdf"
OutputFile = "C:\output.tif"
    
Set imo = CreateObject("ImageMagickObject.MagickImage.1")
                    
imo.Convert InputFile, OutputFile
I have 'ImageMagickObject 1.0 Type Library' checked in the the references section.

I am able to get this to work from a command line by typing Convert input.pdf output.tif, but I would like to get this working from within a VB6 application.

Any help would be greatly appreciated.

Reagan

Re: Method 'Convert' of object 'IMagickImage' failed

Posted: 2009-03-24T10:47:54-07:00
by magick
Install http://www.microsoft.com/downloads/deta ... 02B2AF5FC2 and see if that fixed the problem.

Re: Method 'Convert' of object 'IMagickImage' failed

Posted: 2009-03-24T10:53:00-07:00
by rgoodson40
I installed the Visual C++ redistributable package as you suggested, but I am still getting the same error.

Reagan

Re: Method 'Convert' of object 'IMagickImage' failed

Posted: 2009-03-25T10:08:49-07:00
by rgoodson40
Does anybody have any ideas on how I can get ImageMagick working inside a Visual Basic 6 application? This appears to be the exact same issue that the person that posted the "run time error" topic was having, so others are obviously having this problem too, not just me.

Surely someone has gotten ImageMagick to work within a VB app before?

Re: Method 'Convert' of object 'IMagickImage' failed

Posted: 2009-10-08T13:27:15-07:00
by roach
I'm bumping this, since I'm having the same issue. I've installed the C++ redist package. Method "Convert" of object "IMagickImage" failed. (Runtime error -2147418113 (8000ffff)).

Here's the code:

Code: Select all

Dim img As New MagickImage
img.convert "C:\input.jpg", "resize", maxWidth & "x" & maxHeight, "C:\output.gif"


If anyone has an idea how to use the MagickImage OLE object in VB6 or VBA, please let me know?

Re: Method 'Convert' of object 'IMagickImage' failed

Posted: 2009-10-08T13:53:07-07:00
by roach
Changed my code to:

Code: Select all

Dim img As Object
Set img = CreateObject("ImageMagickObject.MagickImage.1")

img.convert "C:\input.jpg", "-resize", maxWidth & "x" & maxHeight, "C:\output.gif"
And everything works fine now. I guess that leading dash in front of "resize" was the problem, as well as needing to late bind the IMagick object.

Re: Method 'Convert' of object 'IMagickImage' failed

Posted: 2010-01-04T12:11:04-07:00
by spieler
Early binding no longer works. See my post at

viewtopic.php?f=3&t=14461

Feel free to reply to that one as I didn't get very far.

Re: Method 'Convert' of object 'IMagickImage' failed

Posted: 2010-02-11T22:53:18-07:00
by ajlaw
I had a lot of trouble with the NEW statement. These posts helped me a lot so I am posting this example here.

This works for me in msword. As you all know you have to add the object by going to the tools -> references menu

Sub ImageMagickResize(wnamein, wnameout, wpercent)
' Dim imgobj As MagickImage
Dim strDPI As String
Dim strFile As String

Set imgobj = CreateObject("ImageMagickObject.MagickImage.1")
imgobj.Convert wnamein, "-resize", CStr(wpercent) + "%", wnameout
Set imgobj = Nothing
End Sub

Cheers

Adam

Re: Method 'Convert' of object 'IMagickImage' failed

Posted: 2011-04-16T03:58:20-07:00
by hrc
Hello,
Facing the same problem of not being able to use the MagickImageObject COM in VB6. The app displays the error:
Method 'Convert' of 'IMagickImage' failed.
I am using VB6 and here is the code:

Dim IM_Obj As New ImageMagickObject.MagickImage
IM_Obj.convert "D:\Temp\Skewed.tif", "-Deskew", 1, "D:\Temp\DeSkewed.tif"

Any help appreciated!

Re: Method 'Convert' of object 'IMagickImage' failed

Posted: 2011-05-07T04:16:08-07:00
by Bredt
Hi,

First, you have to add a reference in VB to "ImageMagikObject 1.0 Type Library". In VB6 menu: Project, References...
Very important: Then in your code, do not "dim" your object as a ImageMagickObject.MagickImage or MagickImage but as a simple Object
Don't forget to "set" this object.

For example:

Code: Select all

'Dim your object as a simple Object
Dim imgMkObj as Object

'Set your object
Set imgMkObj = CreateObject("ImageMagickObject.MagickImage.1")

'Convert your image
MsgBox imgMkObj.Convert("C:\source.jpg", "-resize=800x600", "C:\destination.jpg")

Regards,
Bredt