beernuts Posted October 3, 2006 Share Posted October 3, 2006 This code takes the file and pathname from edit1 infobox in my GUI and sends it to MSpaint to make a thumbnail 200 pixels high and saves that thumbnail in the same place as the original file but rewrites the file name to include "_thumb.jpg" There's a tiny bit of math in it to maintain the correct aspect ratio allthough sometimes the picture will be cropped a tiny bit, 2 pixels max. If you want the height to be different than 200 you could call another value from your GUI or change the value in $heightfixer in the code. expandcollapse popup$thumbnameandpath = ControlGetText("My GUI" , "" , "Edit1") $digitsinthumbpath = StringLen($thumbnameandpath) $numberfromleftinfilename = StringInStr($thumbnameandpath, "\" ,0, -1) $OriginalFNNoPath= stringtrimleft($thumbnameandpath, $numberfromleftinfilename) $cutthumbextension = StringTrimRight($thumbnameandpath, 4) $newthumbname = $cutthumbextension & "_thumb.jpg" run("mspaint.exe") WinWaitActive("untitled - Paint") send("^o") WinWaitActive("Open") send($thumbnameandpath) sleep(1000) send("!o") WinWaitActive($OriginalFNNoPath) send("^e") WinWaitActive("Attributes") $originalwidth = ControlGetText("Attributes", "", "Edit1") $originalheight = ControlGetText("Attributes", "", "Edit2") send("{ENTER}") WinWaitActive($OriginalFNNoPath) send("^w") WinWaitActive("Stretch and Skew") $heightfixer = 200 / $originalheight $heightpercentshrink = $heightfixer * 100 $newpercentage = Ceiling($heightpercentshrink) Send($newpercentage) sleep(500) send("{TAB}") sleep(500) Send($newpercentage) sleep(500) send("{ENTER}") WinWaitActive($OriginalFNNoPath) send("^e") WinWaitActive("Attributes") send("{TAB}") sleep(500) Send("200") sleep(500) send("{ENTER}") WinWaitActive($OriginalFNNoPath) send("!f") sleep(200) send("a") WinWaitActive("Save As") send($newthumbname) sleep(500) send("!s") sleep(2000) send("!{F4}") Link to comment Share on other sites More sharing options...
Zedna Posted October 3, 2006 Share Posted October 3, 2006 You can do this much more elegant way: use IrFanView and it's commnadline Resources UDF ResourcesEx UDF AutoIt Forum Search 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