HomeImagickImagickDrawImagickPixelImagick Pixel IteratorImagick KernelTutorial Source codeReport an issue
Category
Example

Imagick::pingImage

← paintOpaqueImage   pingImageBlob →
This method can be used to query image width, height, size, and format without reading the whole image in to memory.

This method can be used to query image width, height, size, and format without reading the whole image in to memory.


For file: Biter_500.jpg

Width is 500
Height is 400
// Example 1 - File
$image = new \Imagick();
$img_url = "https://phpimagick.com/" . normalisePublicFilePath($this->imageControl->getImagePath());
$fp = fopen($img_url, 'rb');
$image->pingImageFile($fp);
$output .= "For file: " . $img_url . " <br/><br/>";
$output .= "Width is " . $image->getImageWidth() . "<br/>";
$output .= "Height is " . $image->getImageHeight() . "<br/>";
// Example 2
$image = new \Imagick();
$image->pingImage(realpath($this->imageControl->getImagePath()));
$output .= "For file: " . basename($this->imageControl->getImagePath()) . " <br/><br/>";
$output .= "Width is " . $image->getImageWidth() . "<br/>";
$output .= "Height is " . $image->getImageHeight() . "<br/>";
// Example 3 - Blob
$image = new \Imagick();
$image_data = file_get_contents(realpath($this->imageControl->getImagePath()));
$image->pingImageBlob($image_data);
$output .= "For file: " . basename($this->imageControl->getImagePath()) . " <br/><br/>";
$output .= "Width is " . $image->getImageWidth() . "<br/>";
$output .= "Height is " . $image->getImageHeight() . "<br/>";