webCOMAND

#IMAGE

Process an image to either alter the image or get information about it.  See the information about each operation for more details.

Prototype

#IMAGE($image_bytes, $operation, ...)

Parameters

  • image_bytes - The binary data of an image GD Supported Image Format  or ImageMagick Supported Image Format, depending on the enabled image processing engine (typically ImageMagick if available, otherwise GD).  Both support read and write for the popular web formats JPEG, PNG, GIF and BMP.  Both also support XBM, XPM (read-only with GD), WBMP and WebP.
  • operation - What operation to perform on the image data.
    • Annotate - Add text to an image.
    • Blur - Smooth an image to reduce the color contrast between adjacent pixels.
    • Color - Fill an area of the image with a color.
    • ColorFloodFill - Fill an area of the image with the same or similar color within a given tolerance.
    • Composite - Combine the image with another image.
    • Crop - Reduce the size an image by removing edges outside of a rectangular region.
    • Draw - Draw a point, line or shape onto an image.
    • Flip - Vertically mirror image pixels over the X axis to swap the top and bottom.
    • Flop - Horizontally mirror image pixels over the Y axis to swap the left and right.
    • GetExtension - Get the file extension that corresponds to the image format (ie. jpg, png, gif).
    • GetFormat - Get the format of the image data (ie. JPEG, PNG, GIF).
    • GetHeight - Get the height of the image in pixels.
    • GetMime - Get the mime-type of the image.
    • GetVersion - Get the image processing engine (ImageMagick or GD) and version.
    • GetWidth - Get the width of the image in pixels.
    • GreyScale - Convert all colors of an image to the closest matching grey scale value.
    • MotionBlur - Smear/wisp the image in a specific directional and intensity.
    • New - Create a new image based on optional dimensions and color.
    • Resize - Scale the image width and/or height proportionally or independently.
    • Roll - Cycle or shift the pixels left along the X axis and/or down along the Y axis.
    • Rotate - Spin the image a number of degrees around its center.
    • SetFormat - Change the image format.
    • Shadow - Create a faded dark or colored region around the edges of an image.
    • Shear - Skew the image to form a parallelagram with corners that match specified angles.
    • Size - Adjust the width and/or height of the current image canvas without scaling the image.
    • Trim - Crop an image by removing edges that are transparent or of a certain color.
    • Tint - Adjust the image toward a certain color.

Return

The "Get" operation typically return a string or number.  All others return the new version of the image after being processed, or an empty string on error.  See each operation for more information about what it returns.

Example

#/ proportionally resize image to 64 pixels wide
#NEW($Thumbnail)#IMAGE($ImageData, Resize, 64)#ENDNEW

#/ convert it to PNG format
#NEW($Thumbnail)#IMAGE($Thumbnail, SetFormat, PNG)#ENDNEW

#/ write it out to a file and reference it from an image tag
#NEW($Height)#IMAGE($Thumbnail, GetHeight)#ENDNEW
#NEW($ImageURL)#OUTPUT('/img/thumbnail.png',$Thumbnail)#ENDNEW
<img width="64" height="$Height" src="$ImageURL" />

Result

<img width="64" height="52" src="../img/thumbnail.png" />