webCOMAND

#IMAGE

Syntax

#IMAGE(ImageBytes,Operation,...)

Parameters

  • ImageBytes - The binary data of an image in a format recognized by ImageMagick, such as JPG, PNG, GIF, etc.
  • 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.
    • 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.
    • GetVersion - Get the ImageMagick version.
    • GetWidth - Get the width of the image in pixels.
    • GreyScale - Convert all colors of an image to the closest matching grey scale value.
    • 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.
    • MotionBlur - Smear/wisp the image in a specific directional and intensity.
    • 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.

Description

Process an image to either alter the image or get information about it.

Example

#NEW($Thumbnail)#IMAGE($ImageData, Resize, 64)#ENDNEW
#NEW($Thumbnail)#IMAGE($Thumbnail, SetFormat, PNG)#ENDNEW
#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" />

Analysis

Proportionally resize an image to 64 pixels wide, convert it to PNG format, write it out to a file and reference it from an image tag.

Annotate

Syntax

#IMAGE(Image Bytes, Annotate, Font, Point Size, Stroke Color, Fill Color, X, Y, Align, Text, ...)

Parameters

  • Font - Arial, Courier, Generic, Tahoma, Times, Verdana.  Custom True Type fonts may be installed to the webCOMAND fonts folder and referenced by filename.  If no filename extension is specified, ".ttf" is assumed.  Font filenames are not case-sensitive and the installed filename should be all lower-case.  Text styles, such as bold or italic are possible through the use of specifically styled fonts.
  • Point Size - Point size of the font in pixels.
  • Stroke Color - Color used to outline each character (may be "none").
  • Fill Color - Color used to fill each character (may be "none").
  • X - Horizontal offset in pixels from the left edge to start text.
  • Y - Vertical offset in pixels from the top edge to start text.
  • Align - Left, Center, Right.  An empty string will use Gravity to determine alignment.  If Align nor Gravity is specified, Left will be used.
  • Text - String of text characters, which may include newline characters, represented as "\n".  Backslashes are represented with "\\".

    Optional:
     
  • Wrap Width - Number of pixels to extend text before wrapping.  Wrapping will occur at spaces and hyphens when words are shorter than wrap width.  When words are longer than the wrap width, they will be broken into two lines.  An empty string (default) represents no wrap width.  Point Size must be defined in order to wrap text.
  • Fit Width - Increase or decrease the point size in order to fit the longest line of text within the specified width in pixels.  It may be used in conjunction with Wrap Width to first wrap the text to a certain width with a certain Point Size, the scale up the text to fit another width.  If Wrap Width is not specified, but Point Size is, the font size will be reduced to fit within the Fit Width, but will not be increased.  This is useful for producing text that must shrink to fit within a button or region if it is too large, but should use the specified font size otherwise for a consistent size relative to other buttons or regions.  An empty string (default) disables this functionality.
  • Stroke Width - Number of pixels (default is 1) for the outline around each text character.
  • Under Color - Color of background behind the text.  An empty string is used to specify no color (transparent).
  • Line Height - Number of pixels to advance for each line of text, expressed as a decimal multiplied by the height of the font Point Size.  For example, a a Point Size of 12 and Line Height of 1.5 would advance 18 pixels down per line of text.  The default Line Height is dependent on the specified font.  Some fonts do not provide a default line height and therefore may require a Line Height to display text with newlines properly.
  • Kerning - Decimal number of pixels to display between each character.  A negative value can be used to reduce the spacing or overlap characters.  If no value is specified, the default font kerning will be used.  Note, Kerning only works with ImageMagick version 6.4.7-8 or higher.  Check the version with #IMAGE GetVersion.
  • Gravity - If no alignment is provided, these values will position the text relative to the "canvas".  Possible values are: NorthWest, North, NorthEast, West, Center, East, SouthWest, South, SouthEast.
  • Rotate - Number of degrees to rotate the text, as a decimal number.
  • Encoding - Can be used to enable character encoding.  Only one value is valid: "UTF-8".

Description

Place text on an image.

Example

#NEW($Thumbnail)#IMAGE($Image, Annotate, Arial, 12, none, #ccc, 4, 4, 'Hello World')#ENDNEW

Result