PHP | Imagick valid() Function Last Updated : 23 Dec, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report The Imagick::valid() function is an inbuilt function in PHP which is used to check if the current item is valid. Syntax: bool Imagick::valid( void ) Parameters: This function doesn’t accept any parameter. Return Value: This function returns TRUE on success. Exceptions: This function throws ImagickException on error. Below given programs illustrate the Imagick::valid() function in PHP: Program 1: php <?php try { // Create a new imagick object with invalid image $imagick = new Imagick('undefined_source'); if ($imagick->valid()) { echo 'Image is valid'; } } catch (exception $e) { echo 'Image is not valid'; } ?> Output: Image is not valid Program 2: php <?php try { // Create a new imagick object with valid image $imagick = new Imagick( 'https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-13.png'); if ($imagick->valid()) { echo 'Image is valid'; } } catch (exception $e) { echo 'Image is not valid'; } ?> Output: Image is valid Reference: https://www.php.net/manual/en/imagick.valid.php Comment More infoAdvertise with us Next Article PHP | Imagick __toString() Function G gurrrung Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-Imagick Similar Reads PHP | Imagick sampleImage() Function The Imagick::sampleImage() function is an inbuilt function in PHP which is used to scale an image to the desired dimensions with pixel sampling.This method does not introduce any additional color into the scaled image like other resizing methods. Syntax: bool Imagick::sampleImage( int $rows, int $co 1 min read PHP | Imagick readImage() Function The Imagick::readImage() function is an inbuilt function in PHP which is used to read an image from filename. Syntax: bool Imagick::readImage( string $filename ) Parameters:This function accepts a single parameter $filename which holds the name of the file. It can also accept URL of the file. Return 1 min read PHP | Imagick readImages() Function The Imagick::readImages() function is an inbuilt function in PHP which is used to read images from an array of filenames and associate them to a single Imagick object. Syntax: bool Imagick::readImages( array $filenames ) Parameters:This function accepts a single parameter $filenames which holds an a 2 min read PHP | Imagick __toString() Function The Imagick::__toString() function is an inbuilt function in PHP which is used to return the image as a string. This function will only return a single image and should not be used for Imagick objects containing multiple images. Syntax: string Imagick::__toString( void ) Parameters:This function doe 1 min read PHP | Imagick setFormat() Function The Imagick::setFormat() function is an inbuilt function in PHP which is used to set the format of the Imagick object. Syntax: bool Imagick::setFormat( string $format ) Parameters: This function accepts a single parameter $format which holds an string value. Return Value: This function returns TRUE 1 min read PHP | Imagick removeImage() Function The Imagick::removeImage() function is an inbuilt function in PHP which is used to remove an image from the image list. This function removes the current image which is pointed by the cursor. Syntax: bool Imagick::removeImage( void ) Parameters: This function doesnât accepts any parameters. Return V 1 min read Like