Image Analyzer Batch Processing help


The Image Analyzer batch processing language is an extension of the math language used in the Expression evaluator (Help menu or F11). Below is a list of the extended commands. The command arguments correspond to the parameters you can choose in the Image Analyzer program.

To try the following batch processing programs, copy them from your browser and paste to the Process script window in Image Batch.

Image processing commands:
AdaptiveNoiseReduction(FilterSize,SmoothStrenght,ColorNoise,Pyramid | Gauss)
AddText(X,Y,Text,Font,Size,#Color)
ApplyColorMap(FileName)
AutoColorCorrection(Saturation | Luminance | RGB)
AutoBlackWhitePoint
ClearEXIF
CombineWithPrevious(if(p1>p2,p1,p2))
Deinterlace(Odd | Even,Level)
Deskew(#BackgroundColor)
Filter(MaskFileName.fir)
IncreaseLocalContrast(Contrast,FilterSize,Saturation)
Invert
JPEGFilter
MakeGrayscale
Make8bit
Make24bit
MaxSize(MaxWidth,MaxHeight)
MedianFilter(WindowSize)
Mirror
RegisterWithPrevious(MaxShift,MaxScale)
Resize(Width,Height,Bilinear | Pixel | Wiener | Lanczos | Cubic | Sinc | Fract)
ResizeCanvas(Width,Height,X,Y,#Color)
Rotate(AngleDeg,#BackgroundColor)
Sharpen
Smooth(Range)
Stamp(X,Y,FileName)

Output control commands:
SetJPEGQuality(Quality)
SetJPEGSizeLimit(ByteSize)
SetPNGQuality(Quality)
SetPNGFilter(MinSum | Runs | TryAll | None)
SetPluginOptions(OptionString)

Script flow control:
// Comment
SkipNextIf(Condition)
goto(@Label)

Image defines:
Width, Height
BPP
FileName
InputFileSize
OutputFileSize
ImageGamma
Str
Index


A script can be started from the command line, a .BAT file or a Windows shortcut by executing the batch processing program with the script name as argument, e.g.:
c:\Program Files\MeeSoft\ImageAnalyzer\ProcessingPlugins\ImageBatch script.bsc
When all images has been processed, the program will close.

Noise reduction and color correction

This program will apply the adaptive noise reduction filter with Image Analyzer's default parameters, and then do color correction:
AdaptiveNoiseReduction(5,20,0,Gauss)
AutoColorCorrection(Saturation)

Reducing images to half size

Resize(round(Width/2),round(Height/2))

Generating thumbnails for web page

When presenting a large number of images on a website, it is often desirable to make a thumbnail preview of the images. This command will resize the images so that the size is max. 128 x 128 while preserving the height/width ratio.
MaxSize(128,128)
SetJPEGSizeLimit(8*kb)
Furthermore, the HTML code for presenting the images can be generated: If the Log string format is set to a string like

<A HREF="|f"><IMG SRC="thumbnails/|f" BORDER=0></A>

the program will generate the corresponding code in the log window which you can copy to your HTML editor:

<A HREF="PICT0001.JPG"><IMG SRC="thumbnails/PICT0001.JPG" BORDER=0></A>
<A HREF="PICT0002.JPG"><IMG SRC="thumbnails/PICT0002.JPG" BORDER=0></A>
<A HREF="PICT0003.JPG"><IMG SRC="thumbnails/PICT0003.JPG" BORDER=0></A>

Every occurrence of |f in the format string is replaced by the file name.


Limiting the size of compressed images to a specified number of bits

The following two programs will force the images to be compressed so that only 0.5 bits are used per pixel.

For JPEG output:     For JPEG 2000 output:
:MaxBitsPerPixel = 0.5
:Pixels = Width*Height
Pixels
:MaxBits = Pixels*MaxBitsPerPixel
MaxBits
SetJPEGSizeLimit(ceil(MaxBits/8))
:MaxBitsPerPixel = 0.5
SetPluginOptions("rate=" MaxBitsPerPixel/BPP)
These programs can also be used to compare the image quality of JPEG and JPEG 2000. For natural images, 0.5 bits per pixel is sufficient for JPEG 2000, whereas some artefacts are often visible in JPEG images.

Making loops

In the example above the file size was limited by reducing the image quality. Another way of producing smaller files is to reduce the image size. This program uses a loop to repeatedly half the image size until the file size is less than 60 kb.
@Retry
SkipNextIf(OutputFileSize>(60*kb))
  goto(@Done)
Resize(floor(Width/2),floor(Height/2))
goto(@Retry)

@Done

Rotate large images

This (probably quite useless) program will rotate all images with a width of 1000 pixels or above 90° clockwise:
SkipNextIf(Width<1000)
  Rotate(-90)

Adding text

To write text in the center of an image with the system font, use the command:
AddText(Center,Center,"Test!")
This next text example will add yellow text with a black shadow in the upper left corner. The text will be printed in bold Arial size 20:
AddText(11,11,"Test!",Arial Bold,20,#000000)
AddText(10,10,"Test!",Arial Bold,20,#F8AA07)
Numeric values can also be printed in the image. This program will write four lines of text with the image width, height and file size in kb before and after the recompression.
AddText(4,1*16,"File name: " FileName)
AddText(4,2*16,"Width: " Width)
AddText(4,3*16,"Height: " Height)
AddText(4,4*16,"Source file size: " round(InputFileSize/kb) " kb")
AddText(4,5*16,"New file size: " round(OutputFileSize/kb) " kb")

Computing the average of a series of images

CombineWithPrevious(((p1*(Index-1) + p2)/Index)

Adding a logo to the images

The Stamp command will place an image from a specified file in the images processed. If the the stamp image is in PNG format, transparency can be used.
Stamp(Center,8,"c:\graphics\logo.png")

Reading source file list from a text file

Instead of processing all files in a given folder you can also list the files in a text file (with extension .txt or .csv). In that case you should supply the name of the text file in the Source folder edit box (note that the browse dialog cannot be used to select the text file).
It is possible to supply a text for each image in the list by adding a second column separated by ; or |. This text can be printed in the image using the AddText script command. Example:
AddText(4,Height-40,"Text: " Str,Arial Bold,20,#F8AA07)

Adjusting brigheness, contrast or gamma

To make such adjustments you need to save a color map from Image Analyzer's Color Mapper dialog. Set the parameters you need, right click on the map display and select Save. Then you can use ApplyColorMap to apply the saved mapping to the images.
ApplyColorMap(FileName)

Align images

A series of images can be registered to compensate for translation and scale changes.
RegisterWithPrevious(MaxShift,MaxScale)
The maximum allowed translation is 2^MaxShift and the maximum scale change is MaxScale %. Setting MaxScale=0 locks the size.

 

meesoft.logicnet.dk       Last updated 2013-11-03 by Michael Vinther       [Send e-mail]