Jump to content

compress images using autoit code


Recommended Posts

hello dear friends

i have photos of 10gb. I want to compress them. I found that if w open a imge of 3mb in pait and save it i will be compressd into 300kb file. I want to compress all the images. I wrote an autoit code. It's working for one image but the while is not working. Can ne one help me plzz.... my mail id praveenbits.t@gmail.com the code is below with comments

#include <Math.au3>

$flag = 1

$fname = "DSC0"

$fnum = "2703"

While 1=1

Run("mspaint.exe") ;to open paint

WinWaitActive("untitled - Paint") ;to activate untitled - paint

send("^o") ;ctrl+o to open

$total=@ScriptDir & "\" & $fname & $fnum & ".JPG" ;it stores the image path it to the varible

send($total) ;send to path to open the file

send("{ENTER}") ;gives enter

WinWaitActive("Open") ;waits untill image is opened in paint

send("^s") ;saves the file

send("!{F4}") ;alt+F4 to close the file

WinWaitActive("Close") ;waits untill it closes

$fnum=$fnum + 1 ;incriments the image number

Wend

Link to comment
Share on other sites

That is such a waste, to start and restart a program trying to automate it while there is much simpler and efficient way. Look at _ScreenCapture_SaveImage() in the help file. You can modify it to you needs. You can also use _FileListToArray() to list all .jpg files and loop the array in a sane fashion :). About the _ScreenCapture_SaveImage(), if you're saving a JPG file you can specify the percentage of quality to use for the destination image.

Link to comment
Share on other sites

While I can understand wanting to do this by coding it yourself, irfanview can do this real quickly, and it's freeware. but by all means code it yourself, god knows I've done the same thing, coding a regexreplace file renamer just to rename about 30 files, by the time I finished writing and debugging, I would have finished renaming the files if I just went with the windows explorer F2 method, coding is fun!!!!

[size="2"] "Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." - Brian Kernighan[/size]

Link to comment
Share on other sites

#include <Math.au3>

$fname = "DSC"
$fnum = 1

Run("mspaint.exe") ;to open paint
WinWaitActive("untitled - Paint") ;to activate untitled - paint

While $fnum <= 2703
    Send("^o") ;ctrl+o to open
    $total = @ScriptDir & "\" & $fname & StringFormat('%05i',$fnum) & ".JPG" ;it stores the image path it to the varible
    Send($total) ;send to path to open the file
    Send("{ENTER}") ;gives enter
    WinWaitActive("Open") ;waits untill image is opened in paint
    Send("^s") ;saves the file
    While MouseGetCursor() = 15 ; wait till Hourglass cursor dissapears
        Sleep(10)
    WEnd
    $fnum = $fnum + 1 ;incriments the image number
WEnd

Send("!{F4}") ;alt+F4 to close the file
WinWaitActive("Close") ;waits untill it closes

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...