muhmuuh Posted March 8, 2008 Share Posted March 8, 2008 Hello!I want to make image resizor. It would be useful to resize pictures to avatar size or to make thumbnails. I've looked through the help file (mainly the _GDIPlus) functions but did not help function that does it. Than I searched the forum and found this awesome program.http://www.autoitscript.com/forum/index.ph...=58286&st=0It is really really good and does much more things than I want. I looked through its code but I was too complicated to me and did not understand it. I want to make a simple program event without gui and just need to know how to resize particular image. I'm sure I've seen a way how to do it in the forum but can't find it now. Would you please help me?Thanks I ran. I ran until my muscles burned and my veins pumped battery acid. Then I ran some more. Link to comment Share on other sites More sharing options...
Kip Posted March 8, 2008 Share Posted March 8, 2008 do you want to show it resized? (i guess No) [possible with Guictrlcreatepic, and GDIPlus] do wanna save it resized? [possible with GDIPlus] MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API. Link to comment Share on other sites More sharing options...
muhmuuh Posted March 8, 2008 Author Share Posted March 8, 2008 do you want to show it resized? (i guess No) [possible with Guictrlcreatepic, and GDIPlus] do wanna save it resized? [possible with GDIPlus]just to save it resized I ran. I ran until my muscles burned and my veins pumped battery acid. Then I ran some more. Link to comment Share on other sites More sharing options...
Kip Posted March 8, 2008 Share Posted March 8, 2008 then its just like i said: look at GDIPlus in the helpfile. MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API. Link to comment Share on other sites More sharing options...
muhmuuh Posted March 8, 2008 Author Share Posted March 8, 2008 I've looked through those functions but did not find something that can help me. There is _GDIPlus_ImageGetHeight but no _GDIPlus_ImageSetHeight. I'm sure I've seen it here so maybe someone keeps it I ran. I ran until my muscles burned and my veins pumped battery acid. Then I ran some more. Link to comment Share on other sites More sharing options...
Kip Posted March 8, 2008 Share Posted March 8, 2008 Just 6 funcs: _GDIPlus_Startup() _GDIPlus_GraphicsCreateFromHWND() [use a hidden gui] _GDIPlus_ImageLoadFromFile() _GDIPlus_GraphicsDrawImageRectRect() _GDIPlus_ImageSaveToFile() _GDIPlus_Shutdown() MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API. Link to comment Share on other sites More sharing options...
muhmuuh Posted March 8, 2008 Author Share Posted March 8, 2008 OK here is what i've got (copied from RACI by smashly)expandcollapse popup#include <GDIPlus.au3> Func _CreateBitmap($iW, $iH) Local $hWnd, $hDDC, $hCDC, $hBMP $hWnd = _WinAPI_GetDesktopWindow() $hDDC = _WinAPI_GetDC($hWnd) $hCDC = _WinAPI_CreateCompatibleDC($hDDC) $hBMP = _WinAPI_CreateCompatibleBitmap($hDDC, $iW, $iH) _WinAPI_ReleaseDC($hWnd, $hDDC) _WinAPI_DeleteDC($hCDC) Return $hBMP EndFunc ;==>_CreateBitmap Func _GDIPLus_GraphicsDrawImageRect($hGraphics, $hImage, $iX, $iY, $iW, $iH) Local $aResult $aResult = DllCall($ghGDIPDll, "int", "GdipDrawImageRectI", "hwnd", $hGraphics, "hwnd", $hImage, _ "int", $iX, "int", $iY, "int", $iW, "int", $iH) If @error Then Return SetError(@error, @extended, 0) Return SetError($aResult[0], 0, $aResult[0] = 0) EndFunc ;==>_GDIPlus_GraphicsDrawImageRect Global $oSize[3] $oSize[1]=64 $oSize[2]=64 $iPath = FileOpenDialog("Choose image", @DesktopDir & "\", "Images (*.jpg)", 1) $Ext=".jpg" $sPath="C:\" $hBMP = _CreateBitmap($oSize[1], $oSize[2]) ConsoleWrite("a" & @CRLF) $hImage1 = _GDIPlus_BitmapCreateFromHBITMAP($hBMP) ConsoleWrite("b" & @CRLF) $hImage2 = _GDIPlus_ImageLoadFromFile($iPath) $hGraphics = _GDIPlus_ImageGetGraphicsContext($hImage1) ConsoleWrite("c" & @CRLF) _GDIPlus_GraphicsDrawImageRect($hGraphics, $hImage2, 0, 0, $oSize[1], $oSize[2]) ConsoleWrite("d" & @CRLF) $CLSID = _GDIPlus_EncodersGetCLSID(StringUpper($Ext)) $giJPGQuality=100 $tParams = _GDIPlus_ParamInit(1) $tData = DllStructCreate("int Quality") DllStructSetData($tData, "Quality", $giJPGQuality) _GDIPlus_ParamAdd($tParams, $GDIP_EPGQUALITY, 1, $GDIP_EPTLONG, DllStructGetPtr($tData)) If IsDllStruct($tParams) Then $pParams = DllStructGetPtr($tParams) _GDIPlus_ImageSaveToFileEx($hImage1, $sPath & "cool" & StringLower($Ext), $CLSID, $pParams) _GDIPlus_ImageDispose($hImage1) _GDIPlus_ImageDispose($hImage2) _GDIPlus_GraphicsDispose ($hGraphics) _WinAPI_DeleteObject($hBMP)it gives me an error C:\Program Files\AutoIt3\Include\GDIPlus.au3 (482) : ==> Subscript used with non-Array variable.:It seems I'm missing something but can't get whatCan someone please help me? I ran. I ran until my muscles burned and my veins pumped battery acid. Then I ran some more. Link to comment Share on other sites More sharing options...
muhmuuh Posted March 9, 2008 Author Share Posted March 9, 2008 ok, here is what i've got so far #include <GDIPlus.au3> #include <GuiConstantsEx.au3> _GDIPlus_Startup() $iPath = FileOpenDialog("Choose image", @DesktopDir & "\", "Images (*.jpg)", 1) $hImage = _GDIPlus_ImageLoadFromFile ($iPath) $h = _GDIPlus_ImageGetHeight($hImage) $w = _GDIPlus_ImageGetWidth($hImage) $hGUI1 = GUICreate("img", $w, $h, 0, 0) GUISetState() $hGraphic1 = _GDIPlus_GraphicsCreateFromHWND ($hGUI1) ;_GDIPlus_GraphicsDrawImage ($hGraphic1, $hImage, 0, 0) _GDIPlus_GraphicsDrawImageRectRect ($hGraphic1, $hImage, 0, 0, $w, $h, 0, 0, 100, 100) Sleep(5000) _GDIPlus_GraphicsDispose ($hGraphic1) _GDIPlus_ImageDispose ($hImage) _GDIPlus_Shutdown () GUIDelete($hGUI1) This successfully resizes the image to 100x100 and displays it but how can I save it? The function _GDIPlus_GraphicsDrawImageRectRect only returns true or false so I can't use any of the save functions. Do I have to use another function rather than _GDIPlus_GraphicsDrawImageRectRect to resize the image? Thanks I ran. I ran until my muscles burned and my veins pumped battery acid. Then I ran some more. Link to comment Share on other sites More sharing options...
ptrex Posted March 9, 2008 Share Posted March 9, 2008 @muhmuuhMaybe this can get you started.RACIregardsptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
LinuZ Posted March 10, 2008 Share Posted March 10, 2008 @muhmuuh Maybe this can get you started. RACI regards ptrex He has already seen it. OK here is what i've got (copied from RACI by smashly) @muhmuuh In the RACI script you posted there was a command like this: _GDIPlus_ImageSaveToFileEx($hImage1, $sPath & "cool" & StringLower($Ext), $CLSID, $pParams) So it is the _GDIPlus_ImageSaveToFileEx function Use: _GDIPlus_ImageSaveToFileEx($hImage, $sFileName, $sEncoder[, $pParams = 0]) $hImage Handle to an image object $sFileName Fully qualified image file name $sEncoder GUID string of encoder to be used $pParams Pointer to a $tagGDIPPENCODERPARAMS structure Hope you get it working! Link to comment Share on other sites More sharing options...
smashly Posted March 10, 2008 Share Posted March 10, 2008 Hi,expandcollapse popup#include <GDIPlus.au3> #include <WinAPI.au3> ; use this include for _CreateBitmap function Global $oSize[3] $oSize[1] = 64 $oSize[2] = 64 $iPath = FileOpenDialog("Choose image", @DesktopDir & "\", "Images (*.jpg)", 1) $Ext = "jpg" $sPath = "C:\" ;Start up GDIPlus _GDIPlus_Startup () ;Create canvas to put the resized image onto $hBMP = _CreateBitmap($oSize[1], $oSize[2]) $hImage1 = _GDIPlus_BitmapCreateFromHBITMAP($hBMP) ;Load an image file that you want to resize $hImage2 = _GDIPlus_ImageLoadFromFile($iPath) $hGraphics = _GDIPlus_ImageGetGraphicsContext($hImage1) ;Put 2nd image onto the canvas at the desired size _GDIPLus_GraphicsDrawImageRect($hGraphics, $hImage2, 0, 0, $oSize[1], $oSize[2]) ;The encoder to use for the output image $CLSID = _GDIPlus_EncodersGetCLSID(StringUpper($Ext)) ;Save the new image to a file _GDIPlus_ImageSaveToFileEx($hImage1, $sPath & "cool." & StringLower($Ext), $CLSID) ;Clean up resources _GDIPlus_ImageDispose($hImage1) _GDIPlus_ImageDispose($hImage2) _GDIPlus_GraphicsDispose($hGraphics) _WinAPI_DeleteObject($hBMP) ;Shut down GDIPlus _GDIPlus_Shutdown() Func _CreateBitmap($iW, $iH) Local $hWnd, $hDDC, $hCDC, $hBMP $hWnd = _WinAPI_GetDesktopWindow() $hDDC = _WinAPI_GetDC($hWnd) $hCDC = _WinAPI_CreateCompatibleDC($hDDC) $hBMP = _WinAPI_CreateCompatibleBitmap($hDDC, $iW, $iH) _WinAPI_ReleaseDC($hWnd, $hDDC) _WinAPI_DeleteDC($hCDC) Return $hBMP EndFunc ;==>_CreateBitmap Func _GDIPLus_GraphicsDrawImageRect($hGraphics, $hImage, $iX, $iY, $iW, $iH) Local $aResult $aResult = DllCall($ghGDIPDll, "int", "GdipDrawImageRectI", "hwnd", $hGraphics, "hwnd", $hImage, _ "int", $iX, "int", $iY, "int", $iW, "int", $iH) If @error Then Return SetError(@error, @extended, 0) Return SetError($aResult[0], 0, $aResult[0] = 0) EndFunc ;==>_GDIPLus_GraphicsDrawImageRect Cheers Link to comment Share on other sites More sharing options...
ptrex Posted March 10, 2008 Share Posted March 10, 2008 @smashly Func _GDIPLus_GraphicsDrawImageRect($hGraphics, $hImage, $iX, $iY, $iW, $iH) Local $aResult $aResult = DllCall($ghGDIPDll, "int", "GdipDrawImageRectI", "hwnd", $hGraphics, "hwnd", $hImage, _ "int", $iX, "int", $iY, "int", $iW, "int", $iH) If @error Then Return SetError(@error, @extended, 0) Return SetError($aResult[0], 0, $aResult[0] = 0) EndFunc ;==>_GDIPLus_GraphicsDrawImageRect This part does not seem to be needed, correct ? regards ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
smashly Posted March 10, 2008 Share Posted March 10, 2008 Hi ptrex, If your using AutoIt beta 3.2.11.0 then no that function isn't needed. But if your using AutoIt public release 3.2.10.0 then yes the function is needed. The function wasn't added until the 3.2.11.0 beta. Cheers Link to comment Share on other sites More sharing options...
weaponx Posted March 10, 2008 Share Posted March 10, 2008 Why aren't you just using ImageMagick to do this?http://www.autoitscript.com/forum/index.ph...;hl=imagemagick Link to comment Share on other sites More sharing options...
smashly Posted March 10, 2008 Share Posted March 10, 2008 Hi weaponx, Because I didn't want another third party tool to do the job. Even though ImageMagick is faster an more efficient at doing it , not to mention it has a lot more options as well. Even so it was nice to know that it can be done with one third patry program.. AutoIt Cheers Link to comment Share on other sites More sharing options...
ptrex Posted March 10, 2008 Share Posted March 10, 2008 @smashly Great example on how to use GDI. thanks for sharing Regards, ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
Dougiefresh Posted May 3, 2008 Share Posted May 3, 2008 Is there any way to create a transparent BMP? I've changed the extension from JPG to BMP and want to create a transparent BMP. Link to comment Share on other sites More sharing options...
Kip Posted May 3, 2008 Share Posted May 3, 2008 bmp and jpg dont support transparency. But you can set a transparency color:To have a transparent picture it is needed to create the GUI window with WS_EX_LAYERED extended style. The left-top pixel will be used as the transparency color. If several pictures are created the last picture is defining the transparent color. MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API. Link to comment Share on other sites More sharing options...
weaponx Posted May 3, 2008 Share Posted May 3, 2008 Is there any way to create a transparent BMP? I've changed the extension from JPG to BMP and want to create a transparent BMP.Can you change a txt file into an mp3 too? You can't just change the file extension to change the contents of a file. Link to comment Share on other sites More sharing options...
Dougiefresh Posted May 8, 2008 Share Posted May 8, 2008 Can you change a txt file into an mp3 too? You can't just change the file extension to change the contents of a file.OK.... When I said that I changed the extension, I don't mean that I renamed the file. I was talking about the script. I changed:$Ext = "jpg"to$Ext = "bmp"The script now produces a BMP file, not a JPG. And to answer your question, I have seen examples on how to use the speech engine in XP to get the computer to talk out a line of text. I've also seen code to capture audio produced. So, yes, if one was inclined to do so, you could change a text file into a MP3. 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