webCOMAND

ImageData::__construct()

The ImageData constructor creates an object that can be used to process and manipulate the image passed in as binary string data in a format supported by the underlying ImageMagick or GD image library.

Prototype

ImageData __construct(string $image_data)

Parameters

  • image_data - Image as a binary string in a format supported by the underlying ImageMagick or GD image library

Example

// Load the webCOMAND logo image (SVG)
$url = 'https://www.webcomand.com/img/webcomand-logo.svg';
$svg = get_file_contents($url);
$image = new \io_comand_image\models\ImageData($svg);

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

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

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