SetImageDPIByWidth

Adjusts the DPI of the image and optionally resizes based on the expected physical size.

Syntax

bool SetImageDPIByWidth ()

Parameters

ImageWidth: String. Physical width of the page in inches. If not specified, the value defaults to 8.5 inches.

ImageDPI: String. The target DPI for the updated image. If not specified, the value defaults to 300 dpi.

Rescale: String. Indicates if the image should be rescaled. True - rescale image width and height to match the specified DPI and physical size, False - do not rescale the page, just set the DPI.

Smart parameters are supported.

Returns

True, if the operation is successful, else False if any error occurred.

Level

Page level only, and the page must refer to a valid single page image file.

Details

This action is useful for images that do not have a correctly specified DPI or need to be resized based on the expected width. This action adjusts the DPI and the width of the image to the specified DPI. The image can also be resized to the correct logical size based on the expected physical width in inches.

When the rescale parameter is true, the image size is adjusted. The image is scaled proportionally in the horizontal and vertical directions based on the width that has been specified for the image. The final image has the specified DPI and the pixel width and height is scaled to the specified logical size.

Photos typically have a DPI of 72 or 96. While cameras often have a high pixel count, they are unable to correctly set the DPI and physical size of an image. If a camera is used to take a picture of a 8.5"x11" page or a 5" check, the camera cannot correctly set the image properties that reflect the true size of the object. SetImageDPIByWidth can correct these kinds of images. It is typically best to first deskew the image then crop the image in an attempt to retain only the page or check that was photographed. This action will then adjust the image to correct the DPI and physical size. This is important if recognition will be performed on the image. If a photo has a high resolution, recognition can fail if the DPI the image is not within the range of 200 to 300 and if the calculated physical size of the image is incorrect.

SetImageDPIByWidth("6", "", "True")
This example is on a page level rule and sets the image width to 6 inches with a default DPI of 300 while rescaling the image as necessary. Typically, it is best to rescale the image.
SetImageDPIByWidth("6", "300", "False")
This example is on a page level rule and sets the image width to 6 inches without rescaling the image. This will just change the dimensions, leaving the number of pixels unchanged within the image.
SaveImageInformation("","","@P.DPIx","","","","","")
SetImageDPIByWidth("8.5", "@P.DPIx", "True")
This example adjust the image to 8.5" wide and keeps the original DPI of the image. First the action SaveImageInformation obtains the current DPI of the image and stores it in a DCO variable called DPIx. The variable name can be anything meaningful. If the variable does not exist, it will be created. If it does exist, the current value will be overwritten with the new value. Next the action SetImageDPIByWidth adjusts the image to ensure it is 8.5" wide and passes in the current DPI of the image. This will adjust the image so it is 8.5" wide, keeping the original DPI of the image.
SaveImageInformation("","","@P.DPIx","","","","","")
rrCompareNumeric("180",>,"@P.DPIx")
SetImageDPIByWidth("8.5", "@P.DPIx", "True")
This example is similar to the previous example. The difference is that rrCompareNumeric is used to first check the DPI of the image. The image will be adjusted only if the DPI is 180 or less.
SaveImageInformation("","","","","@P.PhysicalWidth","","","")
SetImageDPIByWidth("@P.PhysicalWidth", "300", "True")
This example maintains the same physical width but adjusts the DPI of the image to 300. The technique using SaveImageInformation and smart parameters is similar to the example above. If the image is a low resolution image, increasing the DPI of the image can improve recognition. While it does not make the image sharper it can still help recognition and it can cause some image enhancement operations to work better prior to performing recognition.