Method 'Convert' of object 'IMagickImage' failed

ImageMagickObject is a Windows COM+ interface to ImageMagick. COM+, Visual Basic, and Delphi users should post to this discussion group.
Post Reply
rgoodson40

Method 'Convert' of object 'IMagickImage' failed

Post 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
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

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

Post by magick »

Install http://www.microsoft.com/downloads/deta ... 02B2AF5FC2 and see if that fixed the problem.
rgoodson40

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

Post by rgoodson40 »

I installed the Visual C++ redistributable package as you suggested, but I am still getting the same error.

Reagan
rgoodson40

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

Post 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?
roach

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

Post 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?
roach

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

Post 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.
spieler
Posts: 47
Joined: 2004-10-08T09:03:16-07:00
Location: Iowa

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

Post 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.
ajlaw

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

Post 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
hrc
Posts: 1
Joined: 2011-04-16T03:40:50-07:00
Authentication code: 8675308

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

Post 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!
Bredt
Posts: 1
Joined: 2011-05-07T03:48:46-07:00
Authentication code: 8675308

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

Post 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
Post Reply