webCOMAND

ImageData::get_size()

Get the width and height of the image in pixels.

Prototype

void get_size(int &$width, int &$height)

Parameters

  • width - A variable that will be set to the width of the image, in pixels.
  • height - A variable that will be set to the height of the image, in pixels.

Return

The value of the width and height variables, which are passed-by-reference, are updated, but no value is returned.

Example

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

// get the image width and height, in pixels
$width = $height = NULL;
$image->get_size($width, $height);

// display the image dimensions
echo("Image Dimensions: $width x $height.\n");