imageinfo(
imageinfo(
IMAGEFILE
)

The imageinfo( function returns information about an image file on disk.

Parameters

This function has one parameter:

imagefile – Path and filename of image file.

Description

This function returns a dictionary with information about the specified image file.

    dumpdictionaryquoted(imageinfo("~/Desktop/Image.png")) ☞
        samplesPerPixel="4"
        dpiWidth="72.000"
        dpiHeight="72.000"
        bitsPerSample="8"
        hasAlpha="yes"
        space="RGB"
        pixelHeight="212"
        formatOptions="default"
        profile="HD 709-A"
        pixelWidth="231"
        format="png"
        typeIdentifier="public.png"

Normally you would use the getdictionaryvalue( function to extract items of information about the image, like this.

    local ixinfo
    ixinfo = imageinfo("~/Desktop/Image.png")
    if val(getdictionaryvalue(ixinfo,"pixelHeight")) = val(getdictionaryvalue(ixinfo,"pixelWidth"))
        message "Image is square"
    endif
    if val(getdictionaryvalue(ixinfo,"dpiWidth"))>=144
        message "Retina Image"
    endif

If the specified image file doesn’t exist, the function will return empty text (which can be used by the getdictionaryvalue( function. The example above can be modified to check for a missing image.

    local ixinfo
    ixinfo = imageinfo("~/Desktop/Image.png")
    if ixinfo=""
        message "No image!"
        return
    endif
    ...

Note: Depending on the image, different items of information will be returned, though it will always return common items like height, width, resolution, format, etc. You should always test this function on an image similar to the ones you will be using.

Advanced Note: The imageinfo( function uses the sips shell command to get the information about the image. You can look up the documentation for this shell command for further information about the image that is returned by this function.

See Also

- clipboardimagesave -- saves an image on the clipboard as an image file (.jpg, .png, etc.).
- clipboardimagesize( -- returns the dimensions of whatever image is currently on the computer's clipboard.
- imagedimensions( -- returns the dimensions (height and width) of an image file.

History

Version | Status | Notes
10.0 | New | New in this version.