Help pages about ImageGrab
Download my other software
This page is better viewed in 1024x768.
Last update at
Wednesday, September 15, 2010
. One may open a text file as script
ImageGrab includes a kind of script language, very simple, but useful to launch automatically a set of commands, either on a large number of files at once, or several times. The script command have to be written in a text file (use for instance notepad.exe delivered with Windows).
If you have got a script file on your hard disk (or on a usb key) open it with the button or with the shortcut CTRL+S . Be aware that the script will be launched immediately, without any new action from the user.
If the script was not OK or takes too long to finish, you may abort it with the key Esc.
.The reference of ImageGrab's scripts
A script for ImageGrab is made of a series of lines of text each one representing a single action, with the following syntax:
The list of available commands is displayed when you type F11 or click on the button :
In the first column is the caption, in the second the keyboard shortcut if any is available, in the third the short code for command line switches, in the last the keyword for script (The above list shows only a part of the commands).
Some examples of commands are:
+bmp or +b save the images as bitmap
+open="d:\Mes Documents\Mes vidéos\trucmuche.avi" open an avi file
+position=0:00:00:10 goto timestamp 0:00:00:10 (10th image in the current video). You may also write +>=0:00:00:10
/m or /mute toggle the sound between On and Off
+copy or +c copy the current image to the clipboard
Commands are always separated by blank spaces, or by the end of line in the script. That's why it is important to put parameters with spaces in quotes and not to put blank spaces before or after the equal sign. Only one command may be on a line of script. If there is more text after the parameter, it will be ignored.
Generally speaking if there are lines not compliant with this syntax, they will be ignored. This allows to have comments in the script file, simply with lines not starting with one the three start characters.
The start character may generally be chosen freely among + / -. Nevertheless, for commands that toggle between a true value and a false value, the effect of the sign is different: + forces the value to true, - forces it to false, and / changes the current value to the contrary. For example with the code m, the command +m forces ImageGrab to put the sound off, -m forces ImageGrab to put the sound on and /m changes ImageGrab on that point.
A list of command can be applied to several files in a loop:
At the start of the loop, put a command +open to open files but include wildcards like * or ?. At the end of the loop put the command +next. In this case, ImageGrab opens the first file corresponding to the wildcards when it enters the loop. It applies then the following command until it reaches the command +next where it goes back to the start of the loop and opens the next corresponding file until all files have been processed.
For example, for grabbing the first frame of all files contained in the folder c:\folder you could write the very simple script:
. The same syntax applies for command-line switches
One may launch ImageGrab with command-line switches, by creating a *.bat file with text following the same syntax. Indeed the command line must start with the path and name of the executable of ImageGrab. It is followed by commands written exactly like the script commands, but all in the same line separated with blanks. Be aware that if you use special characters like accents, you should create the file with Wordpad and save it as MS-DOS text.
For instance to extract an image in Jpeg of quality 60 from all mpeg files in the folder d:\My Documents\My videos\, you would write the command line:
"c:\Program Files\ImageGrab\imagegrab_50en.exe" /j=60 -z -e /o="d:\My Documents\My videos\*.mpg" /g ++
if the executable of Imagegrab is in the folder c:\Program Files\ImageGrab. I have added here the commands -z for deleting existing files without confirmation, and -e for not displaying error messages when a file cannot be opened.
A complete script file may be launched in a command-line command with the code s followed by the filename of a script text, like /s="My Documents\script.txt". You may thus launch many commands in a single command-line command.
. Some examples of scripts
Example1: a folder d:\video contains several avi files, and you would like to grab in bmp the 5th frame and the image at 1 second after the start of the video file, without having to confirm deletion of existing bmp files.
-confirm avoiding to confirm deletion of existing images
+bmp save in bmp format
+open="c:\video\*.avi" open all avi files of the folder c:\video
+position=0:00:00:05 go to the 5th frame
+grab grab the current image
+position=0:00:01:00 go to the position 1 second
+grab grab the current image
+next loop until open
Example 2: create a macro command that grabs an image every 30 seconds of the current video file. All images are saved with a filename built with the video filename limited to 8 characters and followed by a number starting with 1. They will be saved in the folder d:\images, and no confirmation will be requested if filenames already exist. Images will be in format Jpeg with quality 75 and normal aspect ratio. Here we do not write a script that will open a file, because the file is already supposed to be loaded in ImageGrab when the script is launched.
+ratio_normal force normal aspect ratio
-confirm no confirmation for deleting existing image files
+j=75 images in Jpeg with quality 75
+filename=8 take the video filename as root limited to 8 characters"
+add_num=0001 add a number, starting with 1 and written with 4 digits
+dest_folder="d:\images" choose the destination folder (NB:if it does not exist it will always be created)
+show_intervallo show intervallometer
+intervallo="30 secondes" start the intervallometer and grab a picture every 30 seconds
-show_intervallo hide intervallometer
Example3: There are wmv files in a folder. Make a slide show presentation with the first image of every video and display it during 10 seconds in full screen.
+open="c:\video\*.wmv" open the wmv files from folder c:\video
+position=0:00:00:00 go to start
+full_screen put full screen
+wait=10000 wait 10 seconds (the parameter is in milliseconds)
+next loop back to open
In the sample scripts, the comments may be included without harm in the text file. They do not change the execution of the script, as long as no word starts with +, / or - and are separated from commands as least by a blank space. It will help to manage the script files, and make future updates.
Help pages for ImageGrab: