webCOMAND

#IMAGE GetFormat

Get the file format used to encode the image bytes.

Prototype

#IMAGE($image_bytes, GetFormat)

Return

A string that represents the file format used to encode the image bytes, such as "GIF", "JPEG", "PDF", "PNG".

If the format is not recognized, an empty string is returned.  This is the proper way to check for recognized image data.  All other "Get" image processors will log an error when unrecognized image bytes are encountered.

Example

#/ get the file extension based on the image format
#NEW($format)#IMAGE($img,GetFormat)#ENDNEW
#IF($format)
    #NEW($ext)#IMAGE($img,GetExtension)#ENDNEW
    <img src="#OUTPUT('thumbnail.$ext',$img)" />
#ELSE
    #WARNING('Unrecognized Format')
#ENDIF