PHP | Imagick pingImageFile() Function
The Imagick::pingImageFile() function is an inbuilt function in PHP which is used to return the image attributes in a lightweighted manner. This function is used to find out metadata about the image without reading the whole image to memory.
Syntex:
bool Imagick::pingImageFile( $filehandle, $fileName )
Parameters: This function accepts two parameters as mentioned above and described below:
- $filehandle: It is mandatory parameter. It opens the file handle to the image.
- $fileName: It is optional parameter. It holds the filename for this image.
Return Value: It returns True on success.
Below program illustrates the Imagick::pingImageFile() function in PHP:
Program:
<?php // Use fopen() function to open file $fp = fopen( "rb"); // Create new imagick object $im = new Imagick(); // Pass the handle to imagick // without loading the memory $im -> pingImageFile($fp); // Getting height of the image echo "The Height of the image is: " . $im->getImageHeight() . "pixel<br>"; // Getting width of the image echo "The Width of the image is: " . $im->getImageWidth() . "pixel"; ?> |
Output:
The Height of the image is: 215 pixel The Width of the image is: 604 pixel
Reference: https://php.net/manual/en/imagick.pingimagefile.php
Recommended Posts:
- PHP | Imagick chopImage() Function
- PHP | Imagick brightnessContrastImage() Function
- PHP | Imagick flipImage() Function
- PHP | Imagick getImageGamma() Function
- PHP | Imagick charcoalImage() Function
- PHP | Imagick spreadImage() Function
- PHP | Imagick statisticImage() Function
- PHP | Imagick shearImage() function
- PHP | Imagick getImageHeight() Function
- PHP | Imagick getImageWidth() Function
- PHP | Imagick getImageColorspace() Function
- PHP | Imagick transverseImage() Function
- PHP | Imagick transposeImage() Function
- PHP | Imagick previewImages() Function
- PHP | Imagick labelImage() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



