logmein Posted March 12, 2009 Share Posted March 12, 2009 I completed it! expandcollapse popup#Region;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_icon=..\insert_image.ico #AutoIt3Wrapper_outfile=..\save.exe #AutoIt3Wrapper_Compression=4 #AutoIt3Wrapper_UseUpx=n #EndRegion;**** Directives created by AutoIt3Wrapper_GUI **** #include <GUIConstants.au3> #include <WIndowsCOnstants.au3> #include <GUIListView.au3> #include <ButtonConstants.au3> #include <GuiComboBox.au3> #include <GuiConstantsEx.au3> #include <GuiComboBoxEx.au3> #include <GDIPlus.au3> #include <File.au3> #include <ProgressConstants.au3> #include <EditCOnstants.au3> _GDIPlus_Startup() Opt('WinTitleMatchMode', 2) HotKeySet('^r', '_remove') Dim $title = 'Perfect Image Converter 2009 1.0.0.0' Dim $x = 'All supported formats (*.JPG;*.JPEG;*.JIB;*.JPC;*.JP2;*.JFIF;*.JIF;*.JPE;*.JNG;*.BMP;*.DIB;*.TIF;*.TIFF;*.PNG;*.GIFF;*. GIF;*.PCX;*.PCD;*.PCC;*.TGA;*.ICO)' #Region ### START Koda GUI section ### Form=C:\Documents and Settings\Welcome\Desktop\Image Tools\imageconverter.kxf $Form = GUICreate($title, 493, 421, -1, -1) $savepath = GUICtrlCreateInput("", 56, 8, 391, 21) $Label1 = GUICtrlCreateLabel("Save to :", 0, 8, 47, 18) $saveb = GUICtrlCreateButton("...", 448, 7, 43, 23, 0) $list = GUICtrlCreateListView("Name|Type|Dimensions|Size|Convert to", 1, 56, 490, 358) $hList = GUICtrlGetHandle($list) GUICtrlSendMsg(-1, 0x101E, 0, 350) GUICtrlSendMsg(-1, 0x101E, 1, 50) GUICtrlSendMsg(-1, 0x101E, 2, 80) GUICtrlSendMsg(-1, 0x101E, 3, 60) GUICtrlSendMsg(-1, 0x101E, 4, 80) $add = GUICtrlCreateButton("&Add", 0, 31, 75, 25, 0) $remove = GUICtrlCreateButton("Remove", 76, 31, 75, 25, 0) $combo1 = GUICtrlCreateCombo("", 154, 32, 154, 25) $hCombo1 = GUICtrlGetHandle($combo1) GUICtrlSetData(-1, 'JPG|JPEG|JIB|JPC|JP2|JFIF|JIF|JPE|JNG|BMP|DIB|TIF|TIFF|PNG|GIFF|GIF|PCX|PCD|PCC|TGA|ICO') $convert = GUICtrlCreateButton("&Convert", 310, 31, 92, 25) GUICtrlSetCursor(-1, 0) $preview = GUICtrlCreateButton('&Preview', 403, 31, 90, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### #Region ### START Koda GUI section ### Form=C:\Documents and Settings\Welcome\Desktop\Image Tools\add.kxf $addform = GUICreate("Add Image", 395 ,135, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_GROUP, $WS_BORDER, $WS_CLIPSIBLINGS), BitOR($WS_EX_TOOLWINDOW, $WS_EX_WINDOWEDGE), $Form) $Group1 = GUICtrlCreateGroup("", 2, 0, 390, 130) $radio1 = GUICtrlCreateLabel("&Add from computer", 9, 16, 113, 17) GUICtrlSetState(-1, $GUI_CHECKED) $Label1 = GUICtrlCreateLabel("Image path (mutiple images seperate by ';')", 9, 40, 208, 18) $path1 = GUICtrlCreateInput("", 9, 64, 321, 22) $bpath1 = GUICtrlCreateButton("...", 330, 63, 27, 25, 0) $expand1 = GUICtrlCreateButton("<>", 357, 63, 27, 25, 0) ;$Radio2 = GUICtrlCreateLabel("A&dd from Internet", 9, 96, 113, 17) ;$Label2 = GUICtrlCreateLabel("Image URL (mutiple images seperate by ';')", 9, 120, 207, 18) ;$path2 = GUICtrlCreateInput("", 9, 144, 345, 22) ;$expand2 = GUICtrlCreateButton("<>", 355, 143, 27, 25, 0) ;$Label3 = GUICtrlCreateLabel("Convert to :", 9, 176, 60, 18) ;$combo2 = GUICtrlCreateCombo("Combo1", 73, 176, 145, 25) ;GUICtrlSetData(-1, "JPG|JPEG|JFIF") ;GUICtrlCreateGroup("", -99, -99, 1, 1) $ok = GUICtrlCreateButton("&Add", 8, 100, 75, 25, 0) GUICtrlSetFont(-1, 10, 800, 0, "Arial") $cancel = GUICtrlCreateButton("&Cancel", 88, 100, 75, 25, 0) GUISetState(@SW_HIDE) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $add GUISetState(@SW_SHOW, $addform) Case $cancel _cancel() Case $bpath1 $bpathgui = FileOpenDialog('Browse for image', @DesktopDir, $x, 1 + 4, '', $addform) If Not @error Then $Split1 = StringSplit($bpathgui, '|') If Not @error Then For $i = 2 To $Split1[0] GUICtrlSetData($path1, GUICtrlRead($path1) & ';' & $Split1[1] & '\' & $Split1[$i]) Next Else GUICtrlSetData($path1, GUICtrlRead($path1) & ';' & $bpathgui) EndIf If StringLeft(GUICtrlRead($path1), 1) = ';' Then GUICtrlSetData($path1, StringTrimLeft(GUICtrlRead($path1), 1)) EndIf If StringRight(GUICtrlRead($path1), 1) = ';' Then GUICtrlSetData($path1, StringTrimRight(GUICtrlRead($path1), 1)) EndIf EndIf Case $expand1 ShellExecute('notepad.exe') If WinWaitActive('Notepad') Then ControlSetText('Notepad', '', 'Edit1', StringReplace(GUICtrlRead($path1), ';', @CRLF)) WinSetTitle('Notepad', '', 'Perfect Image Converter 2009') EndIf Case $ok Local $a, $b, $c, $d $Split2 = StringSplit(GUICtrlRead($path1), ';') For $i = 1 To $Split2[0] If FileExists ($Split2[$i]) = 1 Then _GUICtrlListView_AddItem($list, $Split2[$i]) EndIf Next $count = _GUICtrlListView_GetItemCount($hList) For $i = 0 To $count Dim $selet = _GUICtrlListView_GetItem($hList, $i) Dim $hImage = _GDIPlus_ImageLoadFromFile($selet[3]) Dim $iex = _PathSplit($selet[3], $a, $b, $c, $d) $get = _GUICtrlListView_GetItem($hList, $i) _GUICtrlListView_AddSubItem($hList, $i, Round(FileGetSize($get[3]) / 1024, 1) & ' kB', 3) _GUICtrlListView_AddSubItem($hList, $i, _GDIPlus_ImageGetWidth($hImage) & 'x' & _GDIPlus_ImageGetHeight($hImage), 2) _GUICtrlListView_AddSubItem($hList, $i, StringTrimLeft(StringUpper($iex[4]), 1), 1) Next _cancel() Case $convert _convert() Case $remove _remove() Case $hlist $select = _GUICtrlListView_GetSelectedIndices ($list,True) if not @error Then $info = _GUICtrlListView_GetItem ($list,UBound($select,1),4) _GUICtrlComboBoxEx_SetCurSel ($combo1,_GUICtrlComboBox_SelectString($combo1,$info[3])) $selecteded = _GUICtrlListView_GetSelectedIndices ($list,True) If $selecteded[0] <> 0 Then $m = _GUICtrlListView_GetItem($list, $selecteded[1],5) $se = _GUICtrlComboBox_SelectString($hcombo1,$m[3]) ConsoleWrite ($m[3] & @CRLF & $se) EndIf EndIf Case $combo1 If _GUICtrlListView_GetItemCount($hList) <> 0 Then $selected = _GUICtrlListView_GetSelectedIndices($hList, True) If Not @error And $selected[0] Then _GUICtrlListView_AddSubItem($hList, $selected[1], GUICtrlRead($combo1), 4) EndIf EndIf Case $saveb $gh = FileSelectFolder('Browse for destination directory', @DesktopDir, 1 + 4, GUICtrlRead($savepath), $Form) If Not @error Then GUICtrlSetData($savepath, $gh) EndIf Case $preview ;under construction _preview () EndSwitch WEnd Func _cancel() GUISetState(@SW_HIDE, $addform) GUICtrlSetData($path1, '') ;GUICtrlSetData($path2, '') EndFunc ;==>_cancel Func _remove() GUICtrlSetState($list, $GUI_FOCUS) _GUICtrlListView_GetSelectedIndices($hList, True) $re = _GUICtrlListView_DeleteItemsSelected($hList) _GUICtrlListView_SetItemSelected ($hList,1,true,true) EndFunc ;==>_remove Func _convert() $timer = TimerInit () _GDIPlus_Startup() Local $e, $f, $g, $h , $counter = 0 , $error = 0 Local $saveto = GUICtrlRead($savepath) If FileExists ($saveto) = 0 Then DirCreate ($saveto) If @error Then MsgBox (16,'Error!','Could not create destination directory. Please make sure your entered path valid!','',$Form) EndIf EndIf If $saveto <> '' And _GUICtrlListView_GetItemCount($hList) > 0 Then $count2 = _GUICtrlListView_GetItemCount($hList) If $count2 <> 0 Then For $ii = 0 To $count2 $counter += 1 WinSetTitle($title, '', $title & ' Converting ...') $ex = _GUICtrlListView_GetItem($hList, $ii, 4) $name = _GUICtrlListView_GetItem($hList, $ii) $split3 = _PathSplit($name[3], $e, $f, $g, $h) $image = _GDIPlus_ImageLoadFromFile($name[3]) $CLSID = _GDIPlus_EncodersGetCLSID($ex) $create = _GDIPlus_ImageSaveToFileEx($image, $saveto & '\' & $split3[3] & '.' & $ex[3], $CLSID) If $create = False Then $error += 1 EndIf Next $timerdiff =TimerDiff ($timer) WinSetTitle($title & ' Converting ...', '', $title) _GDIPlus_Shutdown() $q = MsgBox(64+4+512+4096+262144, 'Conversion completed!', 'Report :' & @crlf & @crlf & 'Converted : ' & $counter -1 & @crlf & 'Error(s) : ' & $error & @CRLF & 'Destination dir : ' & $saveto & @CRLF & 'Time : ' & Round($timerdiff/1000,2) & ' s' & @crlf & @crlf & 'Open destination directory?', '', $Form) If $q = 6 Then ShellExecute ($saveto) EndIf Else MsgBox(16, 'Error!', 'Please select the destination directory or add an image to convert list!', '', $Form) EndIf EndIf EndFunc ;==>_convert Func _preview () Local $z, $k , $l , $r $gett = _GUICtrlListView_GetSelectedIndices ($list,true) If $gett[0] <> 0 Then $gettt = _GUICtrlListView_GetItem ($list,$gett[1]) $split4 = _PathSplit ($gettt[3],$z,$k,$l,$r) ShellExecute($gettt[3]) EndIf EndFunc [font=arial, helvetica, sans-serif][s]Total USB Security 3.0 Beta[/s] | [s]Malware Kill[/s] | Malware Scanner | Screen Hider | Locker | Matrix Generator[s]AUTO-SYNC 1.0 | MD5 Hash Generator | URL Checker | Tube Take [/s]| Random Text[/font] Link to comment Share on other sites More sharing options...
jennico Posted April 21, 2009 Share Posted April 21, 2009 noone replies ? i like it. but where is the option to select the output format ? the files created just have no file extension ! j. Spoiler I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.Don't forget this IP: 213.251.145.96 Â Link to comment Share on other sites More sharing options...
blitzkrg Posted April 21, 2009 Share Posted April 21, 2009 didnt work for me. neither the source or the exe source threw error @ this line Dim $x and the exe said unsupported OS vista Link to comment Share on other sites More sharing options...
jennico Posted April 21, 2009 Share Posted April 21, 2009 well, of course you have to correct the line breaks. look into the script and you will see it. j. Spoiler I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.Don't forget this IP: 213.251.145.96 Â Link to comment Share on other sites More sharing options...
torels Posted April 21, 2009 Share Posted April 21, 2009 it's a huge amount of code for an image converter I didn't test it... but it looks good looking at the code the idea isn't bad cheers Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org Link to comment Share on other sites More sharing options...
WideBoyDixon Posted April 21, 2009 Share Posted April 21, 2009 Doesn't work for me. Always gives an error when trying to convert any kind of file. :-O [center]Wide by name, Wide by nature and Wide by girth[u]Scripts[/u]{Hot Folders} {Screen Calipers} {Screen Crosshairs} {Cross-Process Subclassing} {GDI+ Clock} {ASCII Art Signatures}{Another GDI+ Clock} {Desktop Goldfish} {Game of Life} {3D Pie Chart} {Stock Tracker}[u]UDFs[/u]{_FileReplaceText} {_ArrayCompare} {_ToBase}~ My Scripts On Google Code ~[/center] Link to comment Share on other sites More sharing options...
logmein Posted April 21, 2009 Author Share Posted April 21, 2009 It may detect an error if you convert in some format (ex : GIF -> PCC) [font=arial, helvetica, sans-serif][s]Total USB Security 3.0 Beta[/s] | [s]Malware Kill[/s] | Malware Scanner | Screen Hider | Locker | Matrix Generator[s]AUTO-SYNC 1.0 | MD5 Hash Generator | URL Checker | Tube Take [/s]| Random Text[/font] Link to comment Share on other sites More sharing options...
RomanK Posted April 21, 2009 Share Posted April 21, 2009 It replies 'Converted: 1' and 'Error: 1'. It tried converting from jpg to png. The file was created, but it was missing the extension. So, I added .png to the name by myself, and I could open the file. So, you only need to fix your program to make it add the extension to the file name. Good Luck! (I'd take a look at it, too, but I don't have so much time right now.) [font="Courier New"]http://RomanK.hondadesigns.com[/font] Link to comment Share on other sites More sharing options...
jennico Posted April 22, 2009 Share Posted April 22, 2009 (edited) that's what i claimed before. but where did you find the output selection ? all my tests converted to bmp (with error note and without extension). but i had no choice for the output format. j. Edited April 22, 2009 by jennico Spoiler I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.Don't forget this IP: 213.251.145.96 Â Link to comment Share on other sites More sharing options...
RomanK Posted April 22, 2009 Share Posted April 22, 2009 It's the drop-down-box between the Add/Delete buttons and the Converts button. But that's a good point. A selection mode in the Save Dialogue would be better if that's even possible. [font="Courier New"]http://RomanK.hondadesigns.com[/font] Link to comment Share on other sites More sharing options...
ptrex Posted April 22, 2009 Share Posted April 22, 2009 @all If you add 2 lines of code this will sort out the Extension problem. Replace the existing Convert Function by this one. expandcollapse popupFunc _convert() $timer = TimerInit () _GDIPlus_Startup() Local $e, $f, $g, $h , $counter = 0 , $error = 0 Local $saveto = GUICtrlRead($savepath) local $sExt= GUICtrlRead($combo1) If FileExists ($saveto) = 0 Then DirCreate ($saveto) If @error Then MsgBox (16,'Error!','Could not create destination directory. Please make sure your entered path valid!','',$Form) EndIf EndIf If $saveto <> '' And _GUICtrlListView_GetItemCount($hList) > 0 Then $count2 = _GUICtrlListView_GetItemCount($hList) If $count2 <> 0 Then For $ii = 0 To $count2 $counter += 1 WinSetTitle($title, '', $title & ' Converting ...') $ex = _GUICtrlListView_GetItem($hList, $ii, 4) $name = _GUICtrlListView_GetItem($hList, $ii) $split3 = _PathSplit($name[3], $e, $f, $g, $h) $image = _GDIPlus_ImageLoadFromFile($name[3]) $CLSID = _GDIPlus_EncodersGetCLSID($ex) $create = _GDIPlus_ImageSaveToFileEx($image, $saveto & '\' & $split3[3] & '.' & $sExt, $CLSID) If $create = False Then $error += 1 EndIf Next $timerdiff =TimerDiff ($timer) WinSetTitle($title & ' Converting ...', '', $title) _GDIPlus_Shutdown() $q = MsgBox(64+4+512+4096+262144, 'Conversion completed!', 'Report :' & @crlf & @crlf & 'Converted : ' & $counter -1 & @crlf & 'Error(s) : ' & $error & @CRLF & 'Destination dir : ' & $saveto & @CRLF & 'Time : ' & Round($timerdiff/1000,2) & ' s' & @crlf & @crlf & 'Open destination directory?', '', $Form) If $q = 6 Then ShellExecute ($saveto) EndIf Else MsgBox(16, 'Error!', 'Please select the destination directory or add an image to convert list!', '', $Form) EndIf EndIf 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...
vengat Posted April 23, 2009 Share Posted April 23, 2009 cool converter tool , i should give it a try! vengat , cool of all Link to comment Share on other sites More sharing options...
Dolemite50 Posted April 29, 2009 Share Posted April 29, 2009 It worked fine for me, thanks for sharing! Link to comment Share on other sites More sharing options...
Dolemite50 Posted April 29, 2009 Share Posted April 29, 2009 Ooops, I spoke too soon. After converting BMP to PNG I was unable to open it in Fireworks. (unknown format). The extension was all caps so I tried changing it to lower but no go. It might just be a matter of Fireworks taking a staunch png-purist stance... that hoighty toighty sommm beech. I have a minor suggestion, when you select either the import or export folder you could have the other default to the same dir in the dialogue. I think 9 times out of 10 the converted file will wind up somewhere in that vicinity. Keep plugging away man, it's interface is nice so you only need a little tweaking to smooth out the edges. My "thanks for sharing" sentiment still stands. 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