Jump to content

Recommended Posts

Posted

I completed it!

#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
  • 1 month later...
Posted

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.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Posted

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.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Posted

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

Posted

Doesn't work for me. Always gives an error when trying to convert any kind of file. :-O

Posted

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]
Posted (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 by jennico
Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Posted

@all

If you add 2 lines of code this will sort out the Extension problem.

Replace the existing Convert Function by this one.

Func _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

Posted

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.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...