#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=crop_icon.ico #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include "Visual Crop UDF 1.0.0.4.au3" #include MsgBox(0,"Image Crop Demo", "These are 4 examples of the Crop function." & @CRLF & "Selecting 'Cancel' in the FileOpenDialog will abort the demo.") Global $sFileName, $sResult $sFileName = FileOpenDialog("1. Select image autosize and ratio 13x19, crosshair, GUI centered", @ScriptDir, "Image (*.jpg;*.bmp;*.png)", 3) If @error Then Exit $sResult = _CropImage($sFileName, False, True, -1, -1, -1, -1, 13, 19) ; autosize and ratio If @error Then MsgBox($MB_ICONWARNING, "Error", "Crop failed! _CropImage() returned error " & @error) Else ConsoleWrite("File cropped to " & $sResult & @CRLF) EndIf $sFileName = FileOpenDialog("2. Select image autosize, crosshair and no ratio (Default)", @ScriptDir, "Image (*.jpg;*.bmp;*.png)", 3) If @error Then Exit $sResult = _CropImage($sFileName, True) ; autosize and no ratio If @error Then MsgBox($MB_ICONWARNING, "Error", "Crop failed! _CropImage() returned error " & @error) Else ConsoleWrite("File cropped to " & $sResult & @CRLF) EndIf $sFileName = FileOpenDialog("3. Select image autosize and ratio 19x13, no crosshair", @ScriptDir, "Image (*.jpg;*.bmp;*.png)", 3) If @error Then Exit $sResult = _CropImage($sFileName, False, False, -1, -1, 50, -1, 19, 13) ; autosize and ratio If @error Then MsgBox($MB_ICONWARNING, "Error", "Crop failed! _CropImage() returned error " & @error) Else ConsoleWrite("File cropped to " & $sResult & @CRLF) EndIf $sFileName = FileOpenDialog("4. Select image ratio 20x20", @ScriptDir, "Image (*.jpg;*.bmp;*.png)", 3) If @error Then Exit $sResult = _CropImage($sFileName, False, True, @DesktopWidth - 600, -1, 50, -1, 20, 20) ; ratio 13x19 If @error Then MsgBox($MB_ICONWARNING, "Error", "Crop failed! _CropImage() returned error " & @error) Else ConsoleWrite("File cropped to " & $sResult & @CRLF) EndIf