Use of imagemagickobject in vba

Disponible uniquement sur Etudier
  • Pages : 2 (345 mots )
  • Téléchargement(s) : 0
  • Publié le : 2 octobre 2010
Lire le document complet
Aperçu du document
Use of ImageMagickObject in VBA
Option Explicit
'Dim img As New ImageMagickObject.MagickImage

Sub test()
Dim SourceFile As String
Dim DestFile As String
Dim DestFile2 As StringDim msg
'Dim img As ImageMagickObject.MagickImage ' Gives error
Dim img As Object

Set img = CreateObject("ImageMagickObject.MagickImage.1")
Debug.Print typename(img)SourceFile = "C:\Program Files\ImageMagick-6.6.4-Q16\ImageMagickObject\Tests\bill_meets_gorilla_screen.jpg"
DestFile = "C:\ProgramFiles\ImageMagick-6.6.4-Q16\ImageMagickObject\Tests\bill_meets_gorilla_mogged.jpg"
DestFile2 = "C:\Program Files\ImageMagick-6.6.4-Q16\ImageMagickObject\Tests\bill_meets_gorilla_mogged2.jpg"

msg = img.Convert(SourceFile, DestFile)
Debug.Print msgmsg = img.Mogrify("-resize", "800x600", DestFile)
Debug.Print msg
msg = img.Convert(DestFile, DestFile2)
Debug.Print msg
End Sub

Sub ScreenCap() 'WORKS
Dim DestFile As StringDim imObject As Object

DestFile = "C:\Program Files\ImageMagick-6.6.4-Q16\ImageMagickObject\Tests\capscreen.jpg"

'Create ImageMagick Object
Set imObject =CreateObject("ImageMagickObject.MagickImage.1")
'Copy selected area to clipboard as picture
Selection.CopyPicture Appearance:=xlScreen, Format:=xlBitmap
'Save clipboard to image named c:\image.jpg
imObject.Convert"clipboard:myimage", "", "-quality", "85", DestFile

End Sub

Sub ScreenCap2() 'WORKS - As above but inverts image first
Dim DestFile As String

Dim imObject As Object

DestFile ="C:\Program Files\ImageMagick-6.6.4-Q16\ImageMagickObject\Tests\capscreen2.jpg"

'Create ImageMagick Object
Set imObject = CreateObject("ImageMagickObject.MagickImage.1")
'Copy selected area toclipboard as picture
Selection.CopyPicture Appearance:=xlScreen, Format:=xlBitmap
'Save clipboard to image named c:\image.jpg
imObject.Convert "clipboard:myimage", "", "-negate", "-quality",...
tracking img