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.
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.
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?
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)).
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.
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
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"
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.
'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")