You are here: Basic Encoding > Encoding Options

Encoding Options

Specifying Input and Output Files

Encoding images with GeoExpress Command Line requires the use of several switches that identity the input and output files. Several more are optional. Many of the switches for input and output options are the same for raster and LiDAR data. For more information about LiDAR options, see Basic LiDAR Switches.

The following table describes the input and output switches:

Input and Output Switches
Switch Value Notes
-convertto8bit   Converts incoming unsigned 16-bit data to unsigned 8-bit data during encoding. The switch gets ignored for input data that is not unsigned 16-bit.
-i string Alternately -input. Identifies the input source file. It can be a full path name, or a path that is relative to the current working directory. Example: -i foo.tif
-if string Alternately -inputformat. Identifies the input format. For acceptable values see -inputformat.
-input string Alternately -i. Identifies the input source file. It can be a full path name, or a path that is relative to the current working directory. Example: -i foo.tif
-inputformat string

Alternately -if. Identifies the input file format. Accepted formats are:

"tif" or "tiff" – TIFF 6.0

"tifw" – TIFF 6.0 with TIFF world file

"tifg" or "geotiff" – GeoTIFF

"bbb" – BIP, BIL or BSQ format

"doq" – Digital Orthophoto Quadrangle (DOQ)

"doq_nc" – DOQ (no clipping)

"ras" or "rast" – Sun Raster

"lan" – ERDAS LAN

"sid" or "mrsid" – MrSID

"jpg" or "jpeg" – JPEG (not JPEG 2000)

"jp2" – JPEG 2000

"bmp" – Bitmap (BMP) (Windows only)

"nitf" – National Imagery Transmission Format 2.0 and 2.1 (NITF)

"img" – ERDAS Imagine

-o string Alternately -output. Identifies the name of the file that GeoExpress creates. It can be a full path, or a path that is relative to the current working directory. Example: -o myfile.sid
-output string Alternately -o. Identifies the name of the file that GeoExpress creates. It can be a full path, or a path that is relative to the current working directory. Example: -o myfile.sid
-of string Alternately -outputformat. Identifies the desired output format of the file that is to be encoded. For accepted formats see -outputformat.
-outputformat string

Alternately -of. Identifies the desired output format of the file that is to be encoded. Accepted formats are:

"mg2" – MrSID Generation 2 (MG2)

"mg3" – MrSID Generation 3 (MG3)

"mg4" – MrSID Generation 4 (MG4)

"gmljp2" – JPEG 2000 (GMLJP2)

“jp2” – JPEG 2000 (Part I)

“nitf” – raw NITF

“nitfjp2” – NITF encoded as JPEG 2000 (JP2)

"tiff" – GeoTIFF

Default output format is MrSID Generation 4.

-removealpha string MG4 and JP2 only.Specifies that the alpha band should be discarded from the source image.

GeoTIFF Limitations

GeoTIFF jobs can be cropped, but they do not have any additional encode options.

Input and Output Defaults

By default, GeoExpress sets the input format based on the input file extension. If the -of switch is not used, GeoExpress ouputs MrSID Generation 4 (MG4).

Examples

-i foo.tif -if tiff (foo.tif is the input file, identified as a TIFF file)

-i foo.data -if tiff (foo.data is an input file forced into being recognized as TIFF)

-i foo.tif (foo.tif is the input file, with a file type of TIFF being inferred by the file extension .tif)

-o foo.sid –of mg2 (creates an MG2 file called foo.sid)

-o foo.sid –of mg3 (creates an MG3 file called foo.sid)

-o foo.sid (creates an MG3 file called foo.sid)

Basic Encoding Switches

The following table describes the basic encoding switches.

Basic Encoding Switches
Switch Value Notes
-alignpixels   Only for use with -reprores. Aligns the output image to an integer multiple of the output resolution. If you reproject an image and change the resolution, you may want to use this switch.
-applyRotation boolean True or false. For images that include rotation metadata, GeoExpress creates rotated output images. True is the default value. If you do not use this switch, GeoExpress creates rotated images by default.
-bandselection string

Alternately -bands. Specifies the bands to extract from the source image and their order in the output image. Number of bands must agree with the target colorspace (for grayscale images a single band must be specified, for RGB images 3 bands, for CMYK images 4 bands). Band numbering starts at 1. REMAINDER specifies 'all the other non-alpha bands'.

Default: REMAINDER.

Example:

-colorspace RGB -bandselection 5,3,2
-colorspace string

Alternately -cs. Specifies the target colorspace. Valid values are "rgb", "cmyk", "gray", "multi" and "same". Target colorspace must agree with the number of bands in the -bandselection argument. Default: "same". For more information see Multispectral Input Images and the RGB Transform.

Example:

-colorspace RGB -bandselection 5,3,2

-compressionratio float Alternately -cr. Cannot be used with -perbandcompressionratio/-pbcr switch. Specifies how much compression is applied to an encoded file. This number is interpreted as a ratio, so a compression ratio of 20 will produce a file that is twenty times smaller than the nominal uncompressed size of the input file. Example: -cr 10
-lossless   MG3, MG4 and JP2 only. Preserves all of the pixel data of the original source image. See Lossless Encoding for more information.
-maxlevels   Creates an output file with the maximum number of zoom levels that the input image supports.
-perbandgroupcompressionratio string

Alternately -pbgcr. Cannot be used with -cr switch. Specifies compression ratios for groups of (non-alpha) bands in the output image. Applies to multispectral output only. See Setting Per-Band Compression Ratios for usage and examples.

-scale sint Alternately -s. Specifies the number of zoom levels, or resolution levels, that the encoded image will have. For MG2, this number must be between 3 and 9 inclusive. For MG3 and MG4, any number greater than zero is supported. For JP2, the acceptable values are 1 through 12. (Note: The full resolution or base image is called the zero level and is not counted as one of the zoom levels. For example, setting the zoom level at three will result in three additional resolutions besides the base level.)
-targetsize string Alternately -fs. MG3 and MG4 only. Specifies the desired size of the output file in bytes. For example, -fs 10000creates an MG3 file that is 10000 bytes on disk.
-thumb int Closely related to the -scale switch, specifies the target thumbnail size (in pixels), which is the size of the smallest zoom level. For example, -thumb 32creates a file with the number of zoom levels that comes closest to a 32 x 32 pixel thumbnail.
-watermark string Specifies the name of the watermark image that you want to use. See Watermarks.

NOTE: The -compressionratio and -targetsize switches are mutually exclusive, as are the -compressionratio and -perbandgroupcompressionratio switches. The -s/-scale, -thumb, and -maxlevels switches are mutually exclusive.

Image Rotation

Image rotation metadata describes the direction that an image should point. For example, an image might contain metadata that rotates an image so that it points north. GeoExpress creates rotated images with empty space in the corners. The empty space is compressed so that it does not add to the size of the image. This option is selected by default so that your images are displayed with the correct orientation even in viewers that do not support metadata for image rotation.

The following figure shows a rotated image:

The black areas represent the parts of the image that do not contain data values. In MrSID Generation 4 images, the no-data values are stored in the alpha band. For more information on alpha bands, see Alpha Bands and MrSID.

Multispectral Input Images and the RGB Transform

If no colorspace is specified, GeoExpress sets the output colorspace to match that of the source image (the equivalent of using the -colorspace switch with a value of "same"). Also by default, the RGB color transform (also known as the YIQ transform) is not used when creating multispectral images.

To apply the RGB color transform, enter -colortransform TRUE.

The default behavior is overridden if the input image is a multispectral image that has previously been encoded with the RGB color transform and the colorspace is still "same" (whether by default or by explicit setting). In this case, GeoExpress performs the RGB transform. That is, the output is a multispectral image with the YIQ color transform performed on the red, green and blue bands.

However, if in the above scenario the colorspace is changed to "multispectral", the default behavior for multispectral images prevails. In this case the output is a regular multispectral image with no color transform performed.

Setting Per-Band Compression Ratios

For MG4 output you can specify compression ratios for individual bands using the -perbandgroupcompressionratio or -pbgcr switch. Specify a comma-separated list of <bandgroup>@<ratio>, where <bandgroup> is:

-a comma-separated list of bands ('1,2,3'), and/or

-a range of adjacent bands (in order) indicated by a colon ('1:3'), or

-the default group consisting of all unspecified bands ('REMAINDER')

and <ratio> is:

-the desired lossy compression ratio as a positive integer ('20' means '20:1')

-'L' to indicated 'Lossless' compression

Default: 'REMAINDER@L' (all bands for a multispectral compression are losslessly encoded).

Examples:

'1:3@20' and '1,2,3@20' are equivalent: compress the first three bands at 20:1 and everything else losslessly.

'1:3@20, REMAINDER@50': compress the first three bands at 20:1 and all other non-alpha bands at 50:1. The alpha band is always encoded losslessly.

'1:3@L, REMAINDER@50': compress the first three bands losslessly and all other non-alpha bands at 50:1. The alpha band is always encoded losslessly.

NOTE: If you use the -perbandgroupcompressionratio switch and also specify -colortransform TRUE, then bands 1, 2 and 3 in the output file must all have the same compression ratio.

Lossless Encoding

GeoExpress offers the ability to encode losslessly, which preserves all of the pixel data of the original source image. The resulting MG3, MG4 or JPEG 2000 image will be about half the size of the nominal uncompressed size of the source image. To encode an image losslessly, specify the -lossless switch.

Example

The command

mrsidgeoencoder -i foo.tif -o foo.sid -of mg4 -lossless

creates a lossless MG4 file called foo.sid.

NOTE: Multispectral images are encoded losslessly by default.

Watermarks

You can create images with custom watermarks. GeoExpress supports black and white watermark images in BMP, PNG, and JPEG formats. The watermark repeats across the entire image.

The following figure shows an example of a watermarked image:

NOTE: In versions of GeoExpress before v9.5.3, watermark images were limited to 128 × 128 pixels in size. Watermarks must be no wider and no taller than the output image.