rony2006 Posted December 14, 2015 Share Posted December 14, 2015 Hello,For few day I am trying to make a script for selecting, resizing and save a image on computer but I don't have succes.Can you please help me?My code until now is: expandcollapse popup#include <FileConstants.au3> #include <MsgBoxConstants.au3> #include <GUIConstantsEx.au3> #include <GUIConstantsEx.au3> #include <ScreenCapture.au3> Example() Func Example() ; Create a constant variable in Local scope of the message to display in FileOpenDialog. Local Const $sMessage = "Hold down Ctrl or Shift to choose multiple files." ; Display an open dialog to select a list of file(s). Local $sFileOpenDialog = FileOpenDialog($sMessage, @WindowsDir & "\", "Images (*.jpg;*.jpeg)|Videos (*.avi;*.mpg)", $FD_FILEMUSTEXIST + $FD_MULTISELECT) If @error Then ; Display the error message. MsgBox($MB_SYSTEMMODAL, "", "No file(s) were selected.") ; Change the working directory (@WorkingDir) back to the location of the script directory as FileOpenDialog sets it to the last accessed folder. FileChangeDir(@ScriptDir) Else ; Change the working directory (@WorkingDir) back to the location of the script directory as FileOpenDialog sets it to the last accessed folder. FileChangeDir(@ScriptDir) ; Replace instances of "|" with @CRLF in the string returned by FileOpenDialog. $sFileOpenDialog = StringReplace($sFileOpenDialog, "|", @CRLF) ; Display the list of selected files. MsgBox($MB_SYSTEMMODAL, "", "You chose the following files:" & @CRLF & $sFileOpenDialog) EndIf FileCopy($sFileOpenDialog, "\\dettwfs\tt\Standort Sibiu\998 Sonstiges\Linie cabluri\04. Mentenanta\06. Software Mentenanta\buffer\poza.jpg") EndFunc ;==>Example Sleep (4000) global $hBitmap = "\\dettwfs\tt\Standort Sibiu\998 Sonstiges\Linie cabluri\04. Mentenanta\06. Software Mentenanta\buffer\poza.jpg" global $sBitmap = "\\dettwfs\tt\Standort Sibiu\998 Sonstiges\Linie cabluri\04. Mentenanta\06. Software Mentenanta\buffer\poza.jpg" _GDIPlus_Startup() Global Const $iW = @DesktopWidth, $iH = @DesktopHeight Global $hBitmap = _GDIPlus_ImageLoadFromFile($sBitmap) Sleep (3000) Global $hBitmap_Resized = _GDIPlus_ImageResize($hBitmap, "231", "214") ;resize image _GDIPlus_ImageSaveToFile ($hBitmap_Resized, @ScriptDir & "\\dettwfs\tt\Standort Sibiu\998 Sonstiges\Linie cabluri\04. Mentenanta\06. Software Mentenanta\buffer\pozar.jpg" ) _GDIPlus_ImageDispose($hBitmap) _GDIPlus_ImageDispose($hBitmap_Resized) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteObject($sBitmap) _GDIPlus_Shutdown() Link to comment Share on other sites More sharing options...
TheSaint Posted December 14, 2015 Share Posted December 14, 2015 (edited) Your code is a bit of a mess, especially as everything after the function never gets executed. Such is its state that I really haven't looked beyond the following that stand out.All your paths are incomplete, starting with "\\", as they need to be full paths that include a drive letter.And even in your full path preceded with @ScriptDir in your save command, you still have "\\", which will make it fail.All your Global declarations should be done at the start of your script. Edited December 14, 2015 by TheSaint Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage) Link to comment Share on other sites More sharing options...
rony2006 Posted December 14, 2015 Author Share Posted December 14, 2015 (edited) Ok,So I made the modifications but still the image is not resized.The image gets copied to F:\A\poza.jpg but is not resized and saved with name pozar.jpg.Why? expandcollapse popup#include <FileConstants.au3> #include <MsgBoxConstants.au3> #include <GUIConstantsEx.au3> #include <GUIConstantsEx.au3> #include <ScreenCapture.au3> global $hBitmap = "F:\A\poza.jpg" global $sBitmap = "F:\A\poza.jpg" ; Create a constant variable in Local scope of the message to display in FileOpenDialog. Local Const $sMessage = "Hold down Ctrl or Shift to choose multiple files." ; Display an open dialog to select a list of file(s). Local $sFileOpenDialog = FileOpenDialog($sMessage, @WindowsDir & "\", "Images (*.jpg;*.jpeg)|Videos (*.avi;*.mpg)", $FD_FILEMUSTEXIST + $FD_MULTISELECT) If @error Then ; Display the error message. MsgBox($MB_SYSTEMMODAL, "", "No file(s) were selected.") ; Change the working directory (@WorkingDir) back to the location of the script directory as FileOpenDialog sets it to the last accessed folder. FileChangeDir(@ScriptDir) Else ; Change the working directory (@WorkingDir) back to the location of the script directory as FileOpenDialog sets it to the last accessed folder. FileChangeDir(@ScriptDir) ; Replace instances of "|" with @CRLF in the string returned by FileOpenDialog. $sFileOpenDialog = StringReplace($sFileOpenDialog, "|", @CRLF) ; Display the list of selected files. MsgBox($MB_SYSTEMMODAL, "", "You chose the following files:" & @CRLF & $sFileOpenDialog) EndIf FileCopy($sFileOpenDialog, "F:\A\poza.jpg") Sleep (1000) _GDIPlus_Startup() Global Const $iW = @DesktopWidth, $iH = @DesktopHeight Global $hBitmap = _GDIPlus_ImageLoadFromFile($sBitmap) Sleep (3000) Global $hBitmap_Resized = _GDIPlus_ImageResize($hBitmap, "231", "214") ;resize image _GDIPlus_ImageSaveToFile ($hBitmap_Resized, @ScriptDir & "F:\A\pozar.jpg" ) _GDIPlus_ImageDispose($hBitmap) _GDIPlus_ImageDispose($hBitmap_Resized) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteObject($sBitmap) _GDIPlus_Shutdown() Edited December 14, 2015 by rony2006 Link to comment Share on other sites More sharing options...
rony2006 Posted December 15, 2015 Author Share Posted December 15, 2015 Any ideas, please? Link to comment Share on other sites More sharing options...
Danp2 Posted December 15, 2015 Share Posted December 15, 2015 Check @error after the call to _GDIPlus_ImageResize. Also, you should be passing integers, not strings for the size parameters. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
TheSaint Posted December 15, 2015 Share Posted December 15, 2015 (edited) Good pickup Danp2, I missed the double quotes around the sizes.@rony2006 - You only needed to make the "\\" to a single "\"Now you have created another problem with the following line.@ScriptDir & "F:\A\pozar.jpg"it means you are doubling up on drive letter etc ... as @ScriptDir contains a path that includes the drive letter.You appear to be attempting to fly before learning to walk with your coding.One thing you definitely need to do, is check things with MsgBox's.MsgBox(0, "Path Check", @ScriptDir & "F:\A\pozar.jpg") Edited December 15, 2015 by TheSaint Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage) 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