webCOMAND

ImageData Model

  • Class Name: ImageData
  • Namespace: io_comand_image\models
  • Extends: nothing
  • Implements: nothing

The ImageData model is used to access ImageMagick and GD image processing libraries in a general way, so that either can be utilized.  By default, ImageMagick is utilized when available because it has more built-in functionality and tends to produce much better results.  However, GD still works well for basic image processing and is generally more widely available and installed.  ImageMagick can be a challenge to install in some environments.

For ImageMagick installation instructions, see webCOMAND Windows Computer Set Up.
Not all methods are implemented in GD, so an exception may be thrown when annotate() and other more complex image processing methods are called.  These may be implemented on top of GD at some point, but are not currently available.

Example

// Load a PNG image from the web (PNG)
$url = 'https://www.webcomand.com/docs/img/note.png';
$png = get_file_contents($url);
$image = new \io_comand_image\models\ImageData($png);

// Resize the image proportionally to 16 pixels wide
$image->resize(16, 0);

// Change the image format to JPEG
$image->set_format('JPEG');

// Write the PNG image to the file system
file_put_contents('logo.jpg', $image);

Constants

Alignment

The following constants are used by composite().

  • ALIGN_LEFT
  • ALIGN_CENTER
  • ALIGN_RIGHT

Composite

The following constants are used by composite().

  • COMPOSITE_NO
  • COMPOSITE_ADD
  • COMPOSITE_ATOP
  • COMPOSITE_BLEND
  • COMPOSITE_BUMPMAP
  • COMPOSITE_CLEAR
  • COMPOSITE_COLORBURN
  • COMPOSITE_COLORDODGE
  • COMPOSITE_COLORIZE
  • COMPOSITE_COPYBLACK
  • COMPOSITE_COPYBLUE
  • COMPOSITE_COPY
  • COMPOSITE_COPYCYAN
  • COMPOSITE_COPYGREEN
  • COMPOSITE_COPYMAGENTA
  • COMPOSITE_COPYOPACITY
  • COMPOSITE_COPYRED
  • COMPOSITE_COPYYELLOW
  • COMPOSITE_DARKEN
  • COMPOSITE_DSTATOP
  • COMPOSITE_DST
  • COMPOSITE_DSTIN
  • COMPOSITE_DSTOUT
  • COMPOSITE_DSTOVER
  • COMPOSITE_DIFFERENCE
  • COMPOSITE_DISPLACE
  • COMPOSITE_DISSOLVE
  • COMPOSITE_EXCLUSION
  • COMPOSITE_HARDLIGHT
  • COMPOSITE_HUE
  • COMPOSITE_IN
  • COMPOSITE_LIGHTEN
  • COMPOSITE_LUMINIZE
  • COMPOSITE_MINUS
  • COMPOSITE_MODULATE
  • COMPOSITE_MULTIPLY
  • COMPOSITE_OUT
  • COMPOSITE_OVER
  • COMPOSITE_OVERLAY
  • COMPOSITE_PLUS
  • COMPOSITE_REPLACE
  • COMPOSITE_SATURATE
  • COMPOSITE_SCREEN
  • COMPOSITE_SOFTLIGHT
  • COMPOSITE_SRCATOP
  • COMPOSITE_SRC
  • COMPOSITE_SRCIN
  • COMPOSITE_SRCOUT
  • COMPOSITE_SRCOVER
  • COMPOSITE_SUBTRACT
  • COMPOSITE_THRESHOLD
  • COMPOSITE_XOR

Gravity

The following constants are used by composite().

  • GRAVITY_NORTHWEST
  • GRAVITY_NORTH
  • GRAVITY_NORTHEAST
  • GRAVITY_WEST
  • GRAVITY_CENTER
  • GRAVITY_EAST
  • GRAVITY_SOUTHWEST
  • GRAVITY_SOUTH
  • GRAVITY_SOUTHEAST