Import image files

This tool can be used to import a number of common image formats to Whitebox GAT raster file format. Recognized image file formats include Windows bitmaps (*.bmp), JPEG files (*.jpg), GIF files (*.gif), and PNG files (*.png). TIFF files are not currently supported, although GeoTIFFs may be imported using the ImportGeoTIFF tool. This tool supports import of 24-bit image file structures. 24-bit red-green-blue (RGB) are converted into Whitebox colour-composite rasters with an 'rgb' data scale (Note: in actuality it is a aRGB data).

This import tool will attempt to find a corresponding World File to extract location data, i.e. to set the newly created image's North, South, East, and West coordinates. A World File is a plain text computer data file used by GIS software to georeference raster map images. Small-scale rectangular raster image maps can have an associated World File for GIS map software which describes the location, scale and rotation of the map. These World Files are six-line files with decimal numbers on each line. The name of the file is modeled after the associated image file. The three letters of the image filename extension are altered thus: the second letter of the original filename extension is replaced with the last letter, and, the third letter is replaced with the letter "w." For example, the conventional World File extensions are .jgw, .gfw, and .pgw for .jpg, .gif, and .png image types respectively.

The structure of a six-line World File is as follows:

Line 1: pixel size in the x-direction in map units
Line 2: rotation about y-axis
Line 3: rotation about x-axis
Line 4: pixel size in the y-direction in map units, almost always negative
Line 5: x-coordinate of the center of the upper left pixel
Line 6: y-coordinate of the center of the upper left pixel

The following is an example:


World Files must be located in the same directory as their accompanying image files. Whitebox GAT does not currently support rotation during import, and thus, lines 2 and 3 in the above structure must always be set to zero. Notice that images can be imported to Whitebox without World Files, however the coordinates of the top, bottom, and sides of the image will be set using the number of rows and columns. Also note that Whitebox GAT can import GeoTIFF files using this tool, however, it is not able to read the georeferencing metadata contained within the binary image file, and thus, a World File is needed to retain the georeferencing information.

See Also:


The following is an example of a Python script using this tool:

wd = pluginHost.getWorkingDirectory()
# You may have multiple input files but they must
# be separated by semicolons in the string.
inputFiles = wd + "input1.jpg" + ";" + wd + "input2.png" + ";" + wd + "input3.gif"
args = [inputFiles]
pluginHost.runPlugin("ImportImage", args, False)

This is a Groovy script also using this tool:

def wd = pluginHost.getWorkingDirectory()
// You may have multiple input files but they must
// be separated by semicolons in the string.
def inputFiles = wd + "input1.jpg" + ";" + wd + "input2.png" + ";" + wd + "input3.gif"
String[] args = [inputFiles]
pluginHost.runPlugin("ImportImage", args, false)