nobbe Posted January 8, 2007 Share Posted January 8, 2007 hi all i was using Image magick a long time with perl and i tried it now with autoit as COMobject http://www.imagemagick.org/actually its easy to use but im trying now to write a more general function to use the "command line syntax"CODE;; for use with IMAGE magick .. ; http://www.imagemagick.org/;$IMG = ObjCreate("ImageMagickObject.MagickImage.1"); convert logo.jpg logo.gif$rc = $IMG.Convert("logo.jpg","logo1.gif") ; convert JPG to GIF ;$rc returns width, heigth, original format type (JPEG)MsgBox(0, 'rc:', $rc); convert -size 640x480 logo.jpg logo.gif$rc = $IMG.Convert("-size", "320x240", "logo.jpg","logo1.gif") ; convert JPG to GIF , half sizeMsgBox(0, 'rc:', $rc); -draw 'text 100,100 "Works like magick!"'$str="Works like Magick";$rc = $IMG.Convert("-draw","text 10,20 " & "'" &$str &"'" ,"logo.jpg","logo2.gif") ; MsgBox(0, 'rc:', $rc); with resize too$rc = $IMG.Convert("-size", "320x240", "-draw","text 10,20 'Works like magick'","logo.jpg","logo3.gif") ; MsgBox(0, 'rc:', $rc) Link to comment Share on other sites More sharing options...
nobbe Posted January 8, 2007 Author Share Posted January 8, 2007 For a start i wrote some UDF funktions to it also maybe someone knows how to get stdout information from an COM object?? as the following funtion dumps output to console or stdout $o_object = ObjCreate("ImageMagickObject.MagickImage.1") $rc = $o_object.Identify($infile) --> ;; reading STDOUT or console dosnt work on COM Object?? $var = ConsoleRead() msgbox (0,"console",$var) the rest is my start for imagemagic UDf functions expandcollapse popup; _imagemagick.au3 ; ; for use with IMAGE magick .. ; http://www.imagemagick.org/ ; ;=============================================================================== ; ; Function Name: ; Description: ; Parameter(s): ; ;=============================================================================== ; Func _ImageMagick_Convert($infile, $outfile) local $o_object; local $rc; $o_object = ObjCreate("ImageMagickObject.MagickImage.1") If Not IsObj($o_object) Then Return 0 endif $rc = $o_object.Convert($infile, $outfile) Return 1 EndFunc ;=============================================================================== ;=============================================================================== ; ; Function Name: ; Description: ; Parameter(s): ; ;=============================================================================== ; Func _ImageMagick_Resample($infile, $outfile, $percent) local $o_object; local $rc; local $c; $o_object = ObjCreate("ImageMagickObject.MagickImage.1") If Not IsObj($o_object) Then Return 0 endif $c= $percent & "%x" & $percent & "%" ; ; -sample 25%x25% $rc = $o_object.Convert("-sample", $c, $infile, $outfile) Return 1 EndFunc ;=============================================================================== ; ; Function Name: ; Description: ; Parameter(s): ; ;=============================================================================== ; ; DOESNT WORK YET !! ; ; Func _ImageMagick_Identify($infile) local $o_object; local $rc; local $c; Local $array ; $o_object = ObjCreate("ImageMagickObject.MagickImage.1") If Not IsObj($o_object) Then Return 0 endif ;all output goes to STDOUT :: ? ?? $rc = $o_object.Identify($infile) $var = ConsoleRead() msgbox (0,"console",$var) Return 1 EndFunc ;=============================================================================== ; ; Function Name: ; Description: ; Parameter(s): ; ;=============================================================================== ; Func _ImageMagick_Addtext($infile , $outfile, $posx, $posy , $text) local $o_object; local $rc; local $c; $o_object = ObjCreate("ImageMagickObject.MagickImage.1") If Not IsObj($o_object) Then Return 0 endif ; build text "object" .. ;$rc = $IMG.Convert("-draw","text 10,20 'Works like magick'","logo.jpg","logo3a.gif") ; $c="text " & $posx & "," & $posy & " '" &$text &"'" ; $rc = $o_object.Convert("-draw", $c, $infile, $outfile) ; Return 1 EndFunc oÝ÷ Ù«¢+Øì(ì½ÈÕÍÝ¥Ñ %5µ¥¬¸¸(ì¡ÑÑÀè¼½ÝÝܹ¥µµ¥¬¹½É¼(ì(¥¹±ÕÅÕ½Ðí}¥µµ¥¬¹ÔÌÅÕ½Ðìì(((ÀÌØí¥¹¥±$ôÅÕ½Ðí±½¼¹©ÁÅÕ½Ðìì(ÀÌØí½ÕÑ¥±ôÅÕ½Ðí±½¼¹¥ÅÕ½Ðìì((ÀÌØíÉô}%µ5¥} ½¹ÙÉÐ ÀÌØí¥¹¥±°ÀÌØí½ÕÑ¥±¤ì(í5Í ½à À°Ìäí ½¹ÙÉи¸Ìäì°ÀÌØíɤ((ìÉ͵Á±Á¥ÑÕÉ(ÀÌØí½ÕÑ¥±ôÅÕ½Ðí±½¼Ä¹¥ÅÕ½Ðìì(ÀÌØíÉô}%µ5¥}I͵Á± ÀÌØí¥¹¥±°ÀÌØí½ÕÑ¥±°ÔÀ¤ì%ѼÔÀÍ¥é(í5Í ½à À°ÌäíÉ͵Á±¸¸Ìäì°ÀÌØíɤ((쥹ÑáÐ(ÀÌØí½ÕÑ¥±ôÅÕ½Ðí±½¼È¹¥ÅÕ½Ðìì(ÀÌØíÉô}%µ5¥}ÑáÐ ÀÌØí¥¹¥±°ÀÌØí½ÕÑ¥±°ÈÀ°ÈÀ°ÅÕ½Ðí¡±±¼Ý½É±ÅÕ½Ðì¤( Link to comment Share on other sites More sharing options...
yidabu Posted April 1, 2007 Share Posted April 1, 2007 to get output of identify, must use -format command: Local $ImgIn="D:\yidabu.jpg" Local $Info=_ImageMagick_Identify($ImgIn) MsgBox(64,"",$Info,2) ;=============================================================================== ; ; Function Name: ; Description: ; Parameter(s): ; ;=============================================================================== ; ; DOESNT WORK YET !! ; ; Func _ImageMagick_Identify($infile) local $o_object; local $rc; local $c; Local $array ; $o_object = ObjCreate("ImageMagickObject.MagickImage") If Not IsObj($o_object) Then Return 0 endif ;all output goes to STDOUT :: ? ?? $rc = $o_object.Identify("-format","%m%hx%w",$infile) Return $rc EndFunc my UDF:myReplaceStringInFile suport StringRegExp and subdirectorymyFileListToArray suport StringRegExp and subdirectorymyImageIdentify get all information from image, use Image Magick com supportautoit in Chinaautoit 论坛yidabu成功社区 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now