sambalec Posted April 21, 2009 Share Posted April 21, 2009 hello, how can I automate a split jpeg picture, for example, i need to split 15 % on bottom of my pictures. how can I do ? Thank's a lot ! Sambalec Link to comment Share on other sites More sharing options...
weaponx Posted April 21, 2009 Share Posted April 21, 2009 ImagemagickImagemagick in AutoIt Link to comment Share on other sites More sharing options...
sambalec Posted April 22, 2009 Author Share Posted April 22, 2009 Ok Thank's ! Link to comment Share on other sites More sharing options...
Malkey Posted April 22, 2009 Share Posted April 22, 2009 hello, how can I automate a split jpeg picture, for example, i need to split 15 % on bottom of my pictures. how can I do ? Thank's a lot ! SambalecThis script trims 15% off the bottom of an image. Split insinuates two images as the required output. If this is the case, then, _GDIPlus_BitmapCloneArea() needs to be called again with its parameters focused on the bottom 15% of the image. I hope you find this useful. expandcollapse popup; ; This script trims a percentage of the depth of an image off the bottom of the image selected. ; And saves the new trimmed image to the file name in variable, $sNewName1. #include <GuiConstantsEx.au3> #include <GDIPlus.au3> Opt('MustDeclareVars', 1) Global $hGUI1, $hGUI2, $hBitmap1, $hBitmap2, $hGraphic1, $hGraphic2 Local $fname = FileOpenDialog("First image", "", "All images (*.jpg;*.png;*.gif;*.bmp;)") If @error Then Exit Local $sNewName1 = @ScriptDir & "\GDIPlus_Image1.png" Local $iPercentOffBottom = 15 / 100 ;15% off bottom of image _Main($fname, $sNewName1, $iPercentOffBottom) Func _Main($fname, $sNewName, $iPercentOffBottom) Local $hImage, $iX, $iY, $hClone, $hBackbuffer1, $hBackbuffer2 _GDIPlus_Startup() $hImage = _GDIPlus_ImageLoadFromFile($fname) $iX = _GDIPlus_ImageGetWidth($hImage) $iY = _GDIPlus_ImageGetHeight($hImage) ; Create a GUI for the original image $hGUI1 = GUICreate("Original", $iX, $iY, 0, 0) GUISetState() ;Double buffer for $hGUI1 for Re-paint $hGraphic1 = _GDIPlus_GraphicsCreateFromHWND($hGUI1) $hBitmap1 = _GDIPlus_BitmapCreateFromGraphics($iX, $iY, $hGraphic1) $hBackbuffer1 = _GDIPlus_ImageGetGraphicsContext($hBitmap1) ; Create a GUI for Cloned image $hGUI2 = GUICreate("Clone", $iX, $iY, 0, $iY + 30) GUISetState() ;Double buffer for $hGUI2 for Re-paint $hGraphic2 = _GDIPlus_GraphicsCreateFromHWND($hGUI2) $hBitmap2 = _GDIPlus_BitmapCreateFromGraphics($iX, $iY, $hGraphic2) $hBackbuffer2 = _GDIPlus_ImageGetGraphicsContext($hBitmap2) GUIRegisterMsg(0xF, "MY_PAINT"); Register PAINT-Event 0x000F = $WM_PAINT (WindowsConstants.au3) ; Create 24 bit bitmap clone $hClone = _GDIPlus_BitmapCloneArea($hImage, 0, 0, $iX, $iY - ($iY * $iPercentOffBottom), $GDIP_PXF24RGB) ; Draw original image _GDIPlus_GraphicsDrawImage($hBackbuffer1, $hImage, 0, 0) ; Draw Cloned image _GDIPlus_GraphicsDrawImage($hBackbuffer2, $hClone, 0, 0) ;_GDIPlus_GraphicsDrawImageRectRect ($hGraphic2, $hImage, 0, 0, 200, 200, 0, 0, 400, 300) ; Draw buffer bitmaps to GUI's _GDIPlus_GraphicsDrawImage($hGraphic1, $hBitmap1, 0, 0) _GDIPlus_GraphicsDrawImage($hGraphic2, $hBitmap2, 0, 0) WinSetTitle("Original", "","Original - Image Size WidthxHeight = " & $iX & " x " & $iY) WinSetTitle("Clone", "","Clone - Image Size WidthxHeight = " & $iX & " x " & $iY- ($iY * $iPercentOffBottom)) ; Save bitmap to file _GDIPlus_ImageSaveToFile($hClone, $sNewName) ShellExecute($sNewName) ; Loop until user exits Do Until GUIGetMsg() = $GUI_EVENT_CLOSE ; Clean up screen shot file FileDelete($sNewName) ; Release resources _WinAPI_DeleteObject($hClone) _GDIPlus_ImageDispose($hImage) _WinAPI_DeleteObject($hBitmap1) _WinAPI_DeleteObject($hBitmap2) _GDIPlus_GraphicsDispose($hGraphic1) _GDIPlus_GraphicsDispose($hGraphic2) _GDIPlus_GraphicsDispose($hBackbuffer1) _GDIPlus_GraphicsDispose($hBackbuffer2) _GDIPlus_Shutdown() EndFunc ;==>_Main Func MY_PAINT($hWnd, $msg, $wParam, $lParam) If $hWnd = $hGUI1 Then _GDIPlus_GraphicsDrawImage($hGraphic1, $hBitmap1, 0, 0) If $hWnd = $hGUI2 Then _GDIPlus_GraphicsDrawImage($hGraphic2, $hBitmap2, 0, 0) ;_WinAPI_RedrawWindow($hWnd, "", "", BitOR($RDW_INVALIDATE, $RDW_UPDATENOW, $RDW_FRAME)) ; , $RDW_ALLCHILDREN Return $GUI_RUNDEFMSG EndFunc ;==>MY_PAINT 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