Vbs saves the image file as a drawing mspaint to reduce the size of the image file.

Source: Internet
Author: User

From http://kongjian.baidu.com/sunch721521/blog/item/12cdd633ab47e34bac4b5f20.html

 

'Note :~ Represents press enter, % Represents ALT, ^ represents Ctrl, CTRL + ← represents deletion...
'Set the followingCodeCopy and paste the image to notepad, modify the image path, and save it ?. Vbs
'The image taken by a digital camera occupies a lot of space.ProgramOpen the image and save it as a result. The image effect remains unchanged but is much smaller.
'This vbs can save images in batches
'Function: Save the jpg image in the current image directory (such as E: \ graph) to a new directory (such as E: \ new_graph) to keep the image file name unchanged.
'Set Ws = Createobject ("wscript. Shell ")
'Ws. Run "mspaint zsc.jpg", 1

Dim FSO, pic_file, directory, tmpname, current_url, new_url
Set FSO = Createobject ("scripting. FileSystemObject ")
'Set the location of the file directory
Current_url = inputbox ("directory of the input file, such as D: \ floder (do not include \)")
Set Directory = FSO. getfolder (current_url)
New_url = inputbox ("Enter the saved directory, such as D :( do not include \)")
'Open the Drawing Software
Set Ws = wscript. Createobject ("wscript. Shell ")
WS. Run "C: \ windows \ system32 \ mspaint.exe", 1
Wscript. Sleep 1000

For each pic_file in directory. Files
Tmpname = lcase (pic_file.name)
WS. appactivate "paint"
Wscript. Sleep 10
'Open the file
WS. sendkeys "^ o"
Wscript. Sleep 10
WS. sendkeys current_url & "\" & tmpname
Wscript. Sleep 10
WS. sendkeys "~ "
Wscript. Sleep 10
'Save
WS. sendkeys "% Fa"
Wscript. Sleep 10
WS. sendkeys new_url & "\" & tmpname
Wscript. Sleep 10
WS. sendkeys "~ "
Wscript. Sleep 10
WS. sendkeys "Y"
Next
WS. sendkeys "% FX"

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.