Saturday, November 22, 2025
HomeLanguagesPHP | Imagick readImage() Function

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 Value: This function returns TRUE on success.

Exceptions: This function throws ImagickException on error.

Below programs illustrate the Imagick::readImage() function in PHP:

Program 1:




<?php
  
// Create a new imagick object
$imagick = new Imagick();
  
// Read the image
$imagick->readImage(
  
// Display the image
header("Content-Type: image/png");
echo $imagick->getImageBlob();
?>


Output:

Program 2:




<?php
  
// Create a new imagick object
$imagick = new Imagick();
  
// Read the image
$imagick->readImage(
  
// Display the image
header("Content-Type: image/gif");
echo $imagick->getImagesBlob();
?>


Output:

Reference: https://www.php.net/manual/en/imagick.readimage.php

RELATED ARTICLES

Most Popular

Dominic
32407 POSTS0 COMMENTS
Milvus
97 POSTS0 COMMENTS
Nango Kala
6785 POSTS0 COMMENTS
Nicole Veronica
11932 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12000 POSTS0 COMMENTS
Shaida Kate Naidoo
6907 POSTS0 COMMENTS
Ted Musemwa
7168 POSTS0 COMMENTS
Thapelo Manthata
6864 POSTS0 COMMENTS
Umr Jansen
6850 POSTS0 COMMENTS