Jump to content

ImageMagick Object


ptrex
 Share

Recommended Posts

Look at ptrex's example:

Dim $img
Dim $ret

; Initialize error handler
$oMyError = ObjEvent("AutoIt.Error","MyErrFunc")

$img = ObjCreate("ImageMagickObject.MagickImage.1")

$ret = $img.Convert("C:\Temp\bill_meets_gorilla_screen.jpg", _
        "-resize", "320x200", _
        "-sepia-tone", "70%", _
        "-format", "gif", _
        "C:\Temp\bill_meets_gorilla_screen_NEW.gif")


Func MyErrFunc()
  $HexNumber=hex($oMyError.number,8)
  Msgbox(0,"COM Error Test","We intercepted a COM Error !"   & @CRLF  & @CRLF & _
             "err.description is: " & @TAB & $oMyError.description   & @CRLF & _
             "err.windescription:"   & @TAB & $oMyError.windescription & @CRLF & _
             "err.number is: "   & @TAB & $HexNumber        & @CRLF & _
             "err.lastdllerror is: "   & @TAB & $oMyError.lastdllerror   & @CRLF & _
             "err.scriptline is: "   & @TAB & $oMyError.scriptline   & @CRLF & _
             "err.source is: "   & @TAB & $oMyError.source       & @CRLF & _
             "err.helpfile is: "       & @TAB & $oMyError.helpfile   & @CRLF & _
             "err.helpcontext is: " & @TAB & $oMyError.helpcontext _
            )
  SetError(1); to check for after this function returns
EndfuncoÝ÷ Ø  Ý¢Ø^­ìZ^jëh×6Const $ERROR_SUCCESS = 0

Dim $img
Dim $info
Dim $msgs
Dim $elem
Dim $sMsgs

; Initialize error handler
$oMyError = ObjEvent("AutoIt.Error","MyErrFunc")

; This is the simplest sample I could come up with. It creates
; the ImageMagick COM object and then sends a copy of the IM
; logo out to a JPEG image files on disk.
;
$img = ObjCreate("ImageMagickObject.MagickImage.1")
;
; The methods for the IM COM object are identical to utility
; command line utilities. You have convert, composite, identify,
; mogrify, and montage. We did not bother with animate, and
; display since they have no purpose in this context.
;
; The argument list is exactly the same as the utility programs
; as a list of strings. In fact you should just be able to
; copy and past - do simple editing and it will work. See the
; other samples for more elaborate command sequences and the
; documentation for the utility programs for more details.
;
$sMsgs = $img.Convert("logo:","-format","%m,%h,%w","logo.jpg")
;
; By default - the string returned is the height, width, and the
; type of the image that was output. You can control this using
; the -format "xxxxxx" command as documented by identify.
;

   
MsgBox (0,"info: ","Return = " & $sMsgs)



Func MyErrFunc()
  $HexNumber=hex($oMyError.number,8)
  Msgbox(0,"COM Error Test","We intercepted a COM Error !"   & @CRLF  & @CRLF & _
             "err.description is: " & @TAB & $oMyError.description   & @CRLF & _
             "err.windescription:"   & @TAB & $oMyError.windescription & @CRLF & _
             "err.number is: "   & @TAB & $HexNumber        & @CRLF & _
             "err.lastdllerror is: "   & @TAB & $oMyError.lastdllerror   & @CRLF & _
             "err.scriptline is: "   & @TAB & $oMyError.scriptline   & @CRLF & _
             "err.source is: "   & @TAB & $oMyError.source       & @CRLF & _
             "err.helpfile is: "       & @TAB & $oMyError.helpfile   & @CRLF & _
             "err.helpcontext is: " & @TAB & $oMyError.helpcontext _
            )
  SetError(1); to check for after this function returns
Endfunc

Have a look at FileFindFirstFile in the helpfile. Modify their example to rename all files in a folder. See if you can work it out :)

Link to comment
Share on other sites

Link to comment
Share on other sites

@LOULOU

The "ImageMagickObject.dll" should be the only Dll you need for distributing.

But it needs to be registered "Regsvr32", on each PC you use the script on.

regards

ptrex

In fact my question was :

I try to use my dll witout anathing else but i don't arrive to use it because alone with no installation of imageMagick the dll refuse to be register with an error.

Link to comment
Share on other sites

Is someone working on that already?

I think the list of possible parameters for these functions should be stored in simple text files. This would make it easy to develop these functions, and to make it flexible and extendible if imagemagic functions change in the future. But I am not sure about what would be the best format. We would need parameter name, its format, and if its mandatory. Is it that easy?

ciao

Xandl

Link to comment
Share on other sites

I've just finished creating a library for this.. but all functions say that $img is not declared, even though it's a Global variable. Here's my long script:

_ImageMagick_Convert("test.png", "jpg", "test.jpg")

; Basic Vars
Global $ret = 0
Global $info
Global $msgs
Global $elem
Global $sMsgs
Global Const $ERROR_SUCCESS = 0
; Error handler
Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")
Global $img = ObjCreate("ImageMagickObject.MagickImage.1")
; Error event
Func MyErrFunc()
  $HexNumber=hex($oMyError.number,8)
  Msgbox(0,"ImageMagick Error", "There was an ImageMagick error!"   & @CRLF  & @CRLF & _
             "err.description is: "                                 & @TAB & $oMyError.description   & @CRLF & _
             "err.windescription:"                                  & @TAB & $oMyError.windescription & @CRLF & _
             "err.number is: "                                      & @TAB & $HexNumber & @CRLF & _
             "err.lastdllerror is: "                                & @TAB & $oMyError.lastdllerror & @CRLF & _
             "err.scriptline is: "                                  & @TAB & $oMyError.scriptline & @CRLF & _
             "err.source is: "                                      & @TAB & $oMyError.source & @CRLF & _
             "err.helpfile is: "                                    & @TAB & $oMyError.helpfile & @CRLF & _
             "err.helpcontext is: "                                 & @TAB & $oMyError.helpcontext _
            )
  SetError(1) ; to check for after this function returns
EndFunc

Func _ImageMagick_Convert($sInFile, $sFormat, $sOutFile)
    $ret = $img.Convert($sInFile, _
        "-format", $sFormat, _ 
        $sOutFile)
    Return $ret
EndFunc

Func _ImageMagick_AdaptiveBlur($sInFile, $sRadius, $sOutFile, $sSigma = "")
    If $sSigma Then
        $ret = $img.Convert($sInFile, _
            "-adaptive-blur", $sRadius & "x" & $sSigma, _
            $sOutFile)
    Else
        $ret = $img.Convert($sInFile, _
            "-adaptive-blur", $sRadius, _
            $sOutFile)
    EndIf
    Return $ret
EndFunc

Func _ImageMagick_AdaptiveResize($sInFile, $sGeometry, $sOutFile)
    $ret = $img.Convert($sInFile, _
        "-adaptive-resize", $sGeometry, _
        $sOutFile)
    Return $ret
EndFunc

Func _ImageMagick_AdaptiveSharpen($sInFile, $sRadius, $sOutFile, $sSigma = "")
    If $sSigma Then
        $ret = $img.Convert($sInFile, _
            "-adaptive-sharpen", $sRadius & "x" & $sSigma, _
            $sOutFile)
    Else
        $ret = $img.Convert($sInFile, _
            "-adaptive-sharpen", $sRadius, _
            $sOutFile)
    EndIf
EndFunc

Func _ImageMagick_Affine($sInFile, $sMatrix, $sOutFile)
    $ret = $img.Convert($sInFile, _
        "-affine", $sMatrix, _
        $sOutFile)
    Return $ret
EndFunc

Func _ImageMagick_Alpha($sInFile, $sType, $sOutFile)
    $ret = $img.Convert($sInFile, _
        "-alpha", $sType, _
        $sOutFile)
    Return $ret
EndFunc

Func _ImageMagick_Annotate($sInFile, $sXRotate, $sText, $sOutFile, $sYRotate = "", $sX = "", $sY = "")
    If $sYRotate Then
        If $sX Then
            If $sY Then
                $ret = $img.Convert($sInFile, _
                    "-annotate", $sXRotate & "x" & $sYRotate & $sX & $sY & " " & $sText, _
                    $sOutFile)
            EndIf
        Else
            $ret = $img.Convert($sInFile, _
                "-annotate", $sXRotate & "x" & $sYRotate & " " & $sText, _
                $sOutFile)
        EndIf
    Else
        If $sX Then
            If $sY Then
                $ret = $img.Convert($sInFile, _
                    "-annotate", $sXRotate & $sX & $sY & " " & $sText, _
                    $sOutFile)
            EndIf
        Else
            $ret = $img.Convert($sInFile, _
                "-annotate", $sXRotate & " " & $sText, _
                $sOutFile)
        EndIf
    EndIf
    Return $ret
EndFunc

Func _ImageMagick_Antialias($sInFile, $sOutFile)
    $ret = $img.Convert($sInFile, _
        "-antialias", _
        $sOutFile)
    Return $ret
EndFunc

Func _ImageMagick_Attenuate($sInFile, $sValue, $sOutFile)
    $ret = $img.Convert($sInFile, _
        "-attenuate", $sValue, _
        $sOutFile)
    Return $ret
EndFunc

Func _ImageMagick_Authenticate($sInFile, $sString, $sOutFile)
    $ret = $img.Convert($sInFile, _
        "-authenticate", $sString, _
        $sOutFile)
    Return $ret
EndFunc

Func _ImageMagick_AutoOrient($sInFile, $sOutFile)
    $ret = $img.Convert($sInFile, _
        "-auto-orient", _
        $sOutFile)
    Return $ret
EndFunc

Func _ImageMagick_Backdrop($sInFile, $sColor, $sOutFile)
    $ret = $img.Convert($sInFile, _
        "-backdrop", $sColor, _
        $sOutFile)
    Return $ret
EndFunc

; $sValue may be a percent.
Func _ImageMagick_Bias($sInFile, $sValue, $sOutFile)
    $ret = $img.Convert($sInFile, _
        "-bias", $sValue, _
        $sOutFile)
    Return $ret
EndFunc

Func _ImageMagick_BlackThreshold($sInFile, $sThreshold, $sOutFile)
    $ret = $img.Convert($sInFile, _
        "-black-threshold", $sThreshold, _
        $sOutFile)
    Return $ret
EndFunc

Func _ImageMagick_BluePrimary($sInFile, $sX, $sY, $sOutFile)
    $ret = $img.Convert($sInFile, _
        "-blue-primary", $sX, $sY, _
        $sOutFile)
    Return $ret
EndFunc

Func _ImageMagick_Blur($sInFile, $sRadius, $sOutFile, $sSigma = "")
    If $sSigma Then
        $ret = $img.Convert($sInFile, _
            "-blur", $sRadius & "x" & $sSigma, _
            $sOutFile)
    Else
        $ret = $img.Convert($sInFile, _
            "-blur", $sRadius, _
            $sOutFile)
    EndIf
    Return $ret
EndFunc

; $sColor takes care of -bordercolor.
Func _ImageMagick_Border($sInFile, $sWidth, $sOutFile, $sHeight = "", $sColor = "")
    If $sHeight Then
        If $sColor Then
            $ret = $img.Convert($sInFile, _
                "-border", $sWidth & "x" & $sHeight, _
                "-bordercolor", $sColor, _
                $sOutFile)
        Else
            $ret = $img.Convert($sInFile, _
                "-border", $sWidth & "x" & $sHeight, _
                $sOutFile)
        EndIf
    Else
        If $sColor Then
            $ret = $img.Convert($sInFile, _
                "-border", $sWidth, _
                "-bordercolor", $sColor, _
                $sOutFile)
        Else
            $ret = $img.Convert($sInFile, _
                "-border", $sWidth, _
                $sOutFile)
        EndIf
    EndIf
    Return $ret
EndFunc

Func _ImageMagick_Charcoal($sInFile, $sFactor, $sOutFile)
    $ret = $img.Convert($sInFile, _
        "-charcoal", $sFactor, _
        $sOutFile)
    Return $ret
EndFunc

Func _ImageMagick_Chop($sInFile, $sWidth, $sHeight, $sX, $sY, $sOutFile)
    $ret = $img.Convert($sInFile, _
        "-chop", $sWidth & "x" & $sHeight & $sX & $sY, _
        $sOutFile)
    Return $ret
EndFunc

Func _ImageMagick_Colorize($sInFile, $sValue, $sOutFile)
    $ret = $img.Convert($sInFile, _
        "-colorize", $sValue, _
        $sOutFile)
    Return $ret
EndFunc

Func _ImageMagick_Colors($sInFile, $sValue, $sOutFile)
    $ret = $img.Convert($sInFile, _
        "-colors", $sValue, _
        $sOutFile)
    Return $ret
EndFunc

Func _ImageMagick_Colorspace($sInFile, $sValue, $sOutFile)
    $ret = $img.Convert($sInFile, _
        "-colorspace", $sValue, _
        $sOutFile)
    Return $ret
EndFunc

Func _ImageMagick_Comment($sInFile, $sString, $sOutFile)
    $ret = $img.Convert($sInFile, _
        "-comment", $sString, _
        $sOutFile)
    Return $ret
EndFunc

Func _ImageMagick_Compose($sInFile, $sOperator, $sOutFile)
    $ret = $img.Convert($sInFile, _
        "-compose", $sOperator, _
        $sOutFile)
    Return $ret
EndFunc

Func _ImageMagick_Compress($sInFile, $sType, $sOutFile)
    $ret = $img.Convert($sInFile, _
        "-compress", $sType, _
        $sOutFile)
    Return $ret
EndFunc

Func _ImageMagick_Convolve($sInFile, $sKernel, $sOutFile)
    $ret = $img.Convert($sInFile, _
        "-convolve", $sKernel, _
        $sOutFile)
    Return $ret
EndFunc

Func _ImageMagick_Crop($sInFile, $sWidth, $sOutFile, $sHeight = "", $sX = "", $sY = "")
    If $sHeight Then
        If $sX Then
            If $sY Then
                $ret = $img.Convert($sInFile, _
                    "-crop", $sWidth & "x" & $sHeight & $sX & $sY, _
                    $sOutFile)
            EndIf
        Else
            $ret = $img.Convert($sInFile, _
                "-crop", $sWidth & "x" & $sHeight, _
                $sOutFile)
        EndIf
    Else
        $ret = $img.Convert($sInFile, _
            "-crop", $sWidth, _
            $sOutFile)
    EndIf
    Return $ret
EndFunc

Func _ImageMagick_Cycle($sInFile, $sAmount, $sOutFile)
    $ret = $img.Convert($sInFile, _
        "-cycle", $sAmount, _
        $sOutFile)
    Return $ret
EndFunc

Func _ImageMagick_Density($sInFile, $sWidth, $sOutFile, $sHeight = "")
    If $sHeight Then
        $ret = $img.Convert($sInFile, _
            "-density", $sWidth & "x" & $sHeight, _
            $sOutFile)
    Else
        $ret = $img.Convert($sInFile, _
            "-density", $sWidth, _
            $sOutFile)
    EndIf
    Return $ret
EndFunc

Func _ImageMagick_Depth($sInFile, $sValue, $sOutFile)
    $ret = $img.Convert($sInFile, _
        "-depth", $sValue, _
        $sOutFile)
    Return $ret
EndFunc

Func _ImageMagick_Displace($sInFile, $sHorizontalScale, $sOutFile, $sVerticalScale = "")
    If $sVerticalScale Then
        $ret = $img.Convert($sInFile, _
            "-displace", $sHorizontalScale & "x" & $sVerticalScale, _
            $sOutFile)
    Else
        $ret = $img.Convert($sInFile, _
            "-displace", $sHorizontalScale, _
            $sOutFile)
    EndIf
    Return $ret
EndFunc

Func _ImageMagick_Dissolve($sInFile, $sPercent, $sOutFile)
    $ret = $img.Convert($sInFile, _
        "-dissolve", $sPercent, _
        $sOutFile)
    Return $ret
EndFunc

Func _ImageMagick_Distort($sInFile, $sMethod, $sArgs, $sOutFile)
    $ret = $img.Convert($sInFile, _
        "-distort", $sMethod & " " & $sArgs, _
        $sOutFile)
    Return $ret
EndFunc

Func _ImageMagick_Draw($sInFile, $sString, $sOutFile)
    $ret = $img.Convert($sInFile, _
        "-draw", $sString, _
        $sOutFile)
    Return $ret
EndFunc

Func _ImageMagick_Edge($sInFile, $sRadius, $sOutFile)
    $ret = $img.Convert($sInFile, _
        "-edge", $sRadius, _
        $sOutFile)
    Return $ret
EndFunc

Func _ImageMagick_Emboss($sInFile, $sRadius, $sOutFile)
    $ret = $img.Convert($sInFile, _
        "-emboss", $sRadius, _
        $sOutFile)
    Return $ret
EndFunc

Func _ImageMagick_Enhance($sInFile, $sOutFile)
    $ret = $img.Convert($sInFile, _
        "-enhance", _
        $sOutFile)
    Return $ret
EndFunc

Func _ImageMagick_Extent($sInFile, $sWidth, $sOutFile, $sHeight = "")
    If $sHeight Then
        $ret = $img.Convert($sInFile, _
            "-extent", $sWidth & "x" & $sHeight, _
            $sOutFile)
    Else
        $ret = $img.Convert($sInFile, _
            "-extent", $sWidth, _
            $sOutFile)
    EndIf
    Return $ret
EndFunc

Func _ImageMagick_Fill($sInFile, $sColor, $sOutFile)
    $ret = $img.Convert($sInFile, _
        "-fill", $sColor, _
        $sOutFile)
    Return $ret
EndFunc

Func _ImageMagick_Flip($sInFile, $sOutFile)
    $ret = $img.Convert($sInFile, _
        "-flip", _
        $sOutFile)
    Return $ret
EndFunc

Func _ImageMagick_Frame($sInFile, $sWidth, $sHeight, $sOuterBevelWidth, $sInnerBevelWidth, $sOutFile)
    $ret = $img.Convert($sInFile, _
        "-frame", $sWidth & "x" & $sHeight & $sOuterBevelWidth & $sInnerBevelWidth, _
        $sOutFile)
    Return $ret
EndFunc

Func _ImageMagick_Fuzz($sInFile, $sDistance, $sOutFile)
    $ret = $img.Convert($sInFile, _
        "-fuzz", $sDistance, _
        $sOutFile)
    Return $ret
EndFunc

Func _ImageMagick_Gamma($sInFile, $sValue, $sOutFile)
    $ret = $img.Convert($sInFile, _
        "-gamma", $sValue, _
        $sOutFile)
    Return $ret
EndFunc

Func _ImageMagick_GaussianBlur($sInFile, $sRadius, $sOutFile, $sSigma = "")
    If $sSigma Then
        $ret = $img.Convert($sInFile, _
            "-gaussian-blur", $sRadius & "x" & $sSigma, _
            $sOutFile)
    Else
        $ret = $img.Convert($sInFile, _
            "-gaussian-blur", $sRadius, _
            $sOutFile)
    EndIf
    Return $ret
EndFunc

Func _ImageMagick_GreenPrimary($sInFile, $sX, $sY, $sOutFile)
    $ret = $img.Convert($sInFile, _
        "-green-primary", $sX, $sY, _
        $sOutFile)
    Return $ret
EndFunc

Func _ImageMagick_Implode($sInFile, $sFactor, $sOutFile)
    $ret = $img.Convert($sInFile, _
        "-implode", $sFactor, _
        $sOutFile)
    Return $ret
EndFunc

Func _ImageMagick_Interlace($sInFile, $sType, $sOutFile)
    $ret = $img.Convert($sInFile, _
        "-interlace", $sType, _
        $sOutFile)
    Return $ret
EndFunc

Func _ImageMagick_Interpolate($sInFile, $sType, $sOutFile)
    $ret = $img.Convert($sInFile, _
        "-interpolate", $sType, _
        $sOutFile)
    Return $ret
EndFunc

Func _ImageMagick_Magnify($sInFile, $sFactor, $sOutFile)
    $ret = $img.Convert($sInFile, _
        "-magnify", $sFactor, _
        $sOutFile)
    Return $ret
EndFunc

Func _ImageMagick_Mattecolor($sInFile, $sColor, $sOutFile)
    $ret = $img.Convert($sInFile, _
        "-mattecolor", $sColor, _
        $sOutFile)
    Return $ret
EndFunc

Func _ImageMagick_Median($sInFile, $sRadius, $sOutFile)
    $ret = $img.Convert($sInFile, _
        "-median", $sRadius, _
        $sOutFile)
    Return $ret
EndFunc

Func _ImageMagick_Monochrome($sInFile, $sOutFile)
    $ret = $img.Convert($sInFile, _
        "-monochrome", _
        $sOutFile)
    Return $ret
EndFunc

Func _ImageMagick_Motionblur($sInFile, $sRadius, $sOutFile, $sSigma = "", $sAngle = "")
    If $sSigma And $sAngle Then
        $ret = $img.Convert($sInFile, _
            "-motion-blur", $sRadius & "x" & $sSigma & "+" & $sAngle, _
            $sOutFile)
    ElseIf $sSigma And Not $sAngle Then
        $ret = $img.Convert($sInFile, _
            "-motion-blur", $sRadius & "x" & $sSigma, _
            $sOutFile)
    ElseIf $sAngle And Not $sSigma Then
        $ret = $img.Convert($sInFile, _
            "-motion-blur", $sRadius & "+" & $sAngle, _
            $sOutFile)
    ElseIf Not $sSigma And Not $sAngle Then
        $ret = $img.Convert($sInFile, _
            "-motion-blur", $sRadius, _
            $sOutFile)
    EndIf
    Return $ret
EndFunc

Func _ImageMagick_Negate($sInFile, $sOutFile)
    $ret = $img.Convert($sInFile, _
        "-negate", _
        $sOutFile)
    Return $ret
EndFunc

Func _ImageMagick_Normalize($sInFile, $sOutFile)
    $ret = $img.Convert($sInFile, _
        "-normalize", _
        $sOutFile)
    Return $ret
EndFunc

Func _ImageMagick_Opaque($sInFile, $sColor, $sOutFile)
    $ret = $img.Convert($sInFile, _
        "-opaque", $sColor, _
        $sOutFile)
    Return $ret
EndFunc

Func _ImageMagick_Orient($sInFile, $sOrientation, $sOutFile)
    $ret = $img.Convert($sInFile, _
        "-orient", $sOrientation, _
        $sOutFile)
    Return $ret
EndFunc

Func _ImageMagick_Paint($sInFile, $sRadius, $sOutFile)
    $ret = $img.Convert($sInFile, _
        "-paint", $sRadius, _
        $sOutFile)
    Return $ret
EndFunc

Func _ImageMagick_Polaroid($sInFile, $sAngle, $sOutFile)
    $ret = $img.Convert($sInFile, _
        "-polaroid", $sAngle, _
        $sOutFile)
    Return $ret
EndFunc

Func _ImageMagick_RadialBlur($sInFile, $sAngle, $sOutFile)
    $ret = $img.Convert($sInFile, _
        "-radial-blur", $sAngle, _
        $sOutFile)
    Return $ret
EndFunc

Func _ImageMagick_Raise($sInFile, $sWidth, $sHeight, $sOutFile)
    $ret = $img.Convert($sInFile, _
        "-raise", $sWidth & "x" & $sHeight, _
        $sOutFile)
    Return $ret
EndFunc

Func _ImageMagick_RedPrimary($sInFile, $sX, $sY, $sOutFile)
    $ret = $img.Convert($sInFile, _
        "-red-primary", $sX, $sY, _
        $sOutFile)
    Return $ret
EndFunc

Func _ImageMagick_Resample($sInFile, $sHorizontal, $sVertical, $sOutFile)
    $ret = $img.Convert($sInFile, _
        "-resample", $sHorizontal & "x" & $sVertical, _
        $sOutFile)
    Return $ret
EndFunc

Func _ImageMagick_Resize($sInFile, $sOutFile, $sWidth = "", $sHeight = "", $sFilter = "")
    If $sWidth And $sHeight Then
        If $sFilter Then
            $ret = $img.Convert($sInFile, _
                "-resize", $sWidth & "x" & $sHeight, _
                "-filter", $sFilter, _
                $sOutFile)
        Else
            $ret = $img.Convert($sInFile, _
                "-resize", $sWidth & "x" & $sHeight, _
                $sOutFile)
        EndIf
    ElseIf $sWidth And Not $sHeight Then
        If $sFilter Then
            $ret = $img.Convert($sInFile, _
                "-resize", $sWidth , _
                "-filter", $sFilter, _
                $sOutFile)
        Else
            $ret = $img.Convert($sInFile, _
                "-resize", $sWidth, _
                $sOutFile)
        EndIf
    ElseIf $sHeight And Not $sWidth Then
        If $sFilter Then
            $ret = $img.Convert($sInFile, _
                "-resize", "x" & $sHeight, _
                "-filter", $sFilter, _
                $sOutFile)
        Else
            $ret = $img.Convert($sInFile, _
                "-resize", "x" & $sHeight, _
                $sOutFile)
        EndIf
    EndIf
    Return $ret
EndFunc

Func _ImageMagick_Rotate($sInFile, $sDegrees, $sOutFile)
    $ret = $img.Convert($sInFile, _
        "-rotate", $sDegrees, _
        $sOutFile)
    Return $ret
EndFunc

Func _ImageMagick_SepiaTone($sInFile, $sThreshold, $sOutFile)
    $ret = $img.Convert($sInFile, _
        "-sepia-tone", $sThreshold, _
        $sOutFile)
    Return $ret
EndFunc

Func _ImageMagick_Sharpen($sInFile, $sRadius, $sOutFile, $sSigma = "")
    If $sSigma Then
        $ret = $img.Convert($sInFile, _
            "-sharpen", $sRadius & "x" & $sSigma, _
            $sOutFile)
    Else
        $ret = $img.Convert($sInFile, _
            "-sharpen", $sRadius, _
            $sOutFile)
    EndIf
    Return $ret
EndFunc

Func _ImageMagick_Swirl($sInFile, $sDegrees, $sOutFile)
    $ret = $img.Convert($sInFile, _
        "-swirl", $sDegrees, _
        $sOutFile)
    Return $ret
EndFunc

Func _ImageMagick_Thumbnail($sInFile, $sOutFile, $sWidth = "", $sHeight = "")
    If $sWidth And $sHeight Then
        $ret = $img.Convert($sInFile, _
            "-thumbnail", $sWidth & "x" & $sHeight, _
            $sOutFile)
    ElseIf $sWidth And Not $sHeight Then
        $ret = $img.Convert($sInFile, _
            "-thumbnail", $sWidth, _
            $sOutFile)
    ElseIf $sHeight And Not $sWidth Then
        $ret = $img.Convert($sInFile, _
            "-thumbnail", "x" & $sHeight, _
            $sOutFile)
    EndIf
    Return $ret
EndFunc

Func _ImageMagick_Tint($sInFile, $sValue, $sOutFile)
    $ret = $img.Convert($sInFile, _
        "-tint", $sValue, _
        $sOutFile)
    Return $ret
EndFunc

Func _ImageMagick_Transparent($sInFile, $sColor, $sOutFile)
    $ret = $img.Convert($sInFile, _
        "-transparent", $sColor, _
        $sOutFile)
    Return $ret
EndFunc

Func _ImageMagick_Trim($sInFile, $sOutFile)
    $ret = $img.Convert($sInFile, _
        "-trim", _
        $sOutFile)
    Return $ret
EndFunc

Func _ImageMagick_Watermark($sInFile, $sBrightness, $sOutFile)
    $ret = $img.Convert($sInFile, _
        "-watermark", $sBrightness, _
        $sOutFile)
    Return $ret
EndFunc

:P

[center]"Yes, [our app] runs on Windows as well as Linux, but if you had a Picasso painting, would you put it in the bathroom?" -BitchX.com (IRC client)"I would change the world, but they won't give me the source code." -Unknownsite . blog . portfolio . claimidcode.is.poetry();[/center]

Link to comment
Share on other sites

Maybe would be eaiser to have like a $oimg = _ImageMagikStartup then have the $oimg passed through into the function? Then have an _ImageMagikShutdown ($oImg) that shuts down the COM interface.

;this is how I would do the startup/Shutdown...
Func _ImageMagik_Startup ($error = True, $func = "MyErrFunc")
    While 1
        $oImg = ObjCreate("ImageMagickObject.MagickImage.1")
        If IsObj ($oImg) Then
            $dll = FileOpenDialog ("Open", "", "DLL (*.dll)")
            Run ('Regsvr32 /u"' & $dll & '"')
        Else
            ExitLoop
        EndIf
    WEnd
    If $error = True Then
        $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")
    EndIf
    Return $oImg
EndFunc

Func _ImageMagik_Shutdown (ByRef $oImg)
    $oImg = 0
EndFunc

Great Job BTW :)

Link to comment
Share on other sites

  • 1 month later...
Link to comment
Share on other sites

bah i've read almost all of the replies on this thread and yet it seems quite amusing that no one asked the following questions:

A. why would we need to trouble with all of that if we can just have the .exe convert file "installed" into our script and use it via CMD-LINE sends.

B. what is it exactly that you guys are trying to make ? (and yet again, if it's the usage of ImageMagic through AU3, it's is much easier to add the .exe file then making the user install the entire application in order to use a .dll which you will have to "install" into the script anyways....)

anyhow HF ya'lls... seems like a nice waste of time. but what's time anyways ?! ["Time is not important only life, important" 5th element :)]

[u]My Au3 Scripts:[/u]____________(E)Lephant, A Share download manager (RS/MU etc)Http1.1 Console, The Ez Way!Internet Reconnection Automation Suite & A Macro Recording Tool.SK's Alarm Clock, Playing '.MP3 & .Wav' Files._________________Is GOD a mistake of the Humanity Or the Humanity is a mistake of GOD ?!

Link to comment
Share on other sites

Link to comment
Share on other sites

Ptrex is right, you have to use enumicons.

after that you get the handle to the icon you can, then you save it

all of this with gdiplus functions

edit :

mmm with gdi+ you can't save icon as ico, but only as png, bmp, or jpeg

if you want to save as *.ico files, you will have to work on C++ codes, and convert its to autoit.

Edited by arcker

-- Arck System _ Soon -- Ideas make everything

"La critique est facile, l'art est difficile"

Projects :

[list] [*]Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here [/list]
Link to comment
Share on other sites

  • 1 month later...

I'm having trouble with a "magic" function...Maybe someone can help.

From IM tutorial:

http://www.imagemagick.org/Usage/channels/#mask_diff

convert cyclops.png \( +clone -fx 'p{0,0}' \) \
          -compose Difference  -composite  \
          -modulate 100,0  +matte  difference.png

Now I've tried several ways to process this...

$oMagic.Convert("C:\cyclops.png", "( +clone -fx 'p{0,0}' \)", "-compose", _
    "Difference",  "-composite", "-modulate", "100,0",  "+matte",  "C:\difference.png")oÝ÷ Ù«­¢+Ø$ÀÌØí½5¥¹
½¹ÙÉÐ ÅÕ½ÐíèÀäÈíå±½Á̹Á¹ÅÕ½Ðì°ÅÕ½Ðì­±½¹ÅÕ½Ðì°ÅÕ½ÐìµàÅÕ½Ðì°ÅÕ½ÐíÁìÀ°ÁôÅÕ½Ðì°ÅÕ½Ðìµ½µÁ½ÍÅÕ½Ðì°|($ÅÕ½Ðí¥É¹ÅÕ½Ðì°ÅÕ½Ðìµ½µÁ½Í¥ÑÅÕ½Ðì°ÅÕ½Ðìµµ½Õ±ÑÅÕ½Ðì°ÅÕ½ÐìÄÀÀ°ÀÅÕ½Ðì°ÅÕ½Ðì­µÑÑÅÕ½Ðì°ÅÕ½ÐíèÀäÈí¥É¹¹Á¹ÅÕ½Ðì¤

No luck so far. My syntax is off :D

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...