Wednesday, May 27, 2026
HomeLanguagesPHP | Imagick displayImages() Function

PHP | Imagick displayImages() Function

The Imagick::displayImages() function is an inbuilt function in PHP which is used to display an image or images sequence on an X server.

Syntax:

bool Imagick::displayImages( string $servername )

Parameters: This function accepts single parameter $servername which holds the X server name.

Return Value: This function returns True on success.

Errors/Exceptions: This function throws ImagickException on error.

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

Program 1:




<?php 
  
// Create an Imagick object 
$imagick = new Imagick( 
  
// Use displayImage function 
$imagick->displayImage('servername'); 
  
header("Content-Type: image/jpg"); 
  
// Display the output image 
echo $imagick->getImageBlob(); 
?> 


Output:
imagick::displayImages

Program 2:




<?php 
  
$string = "Computer Science portal for Geeks!"; 
  
// Creating new image of above String 
// and add color and background 
$im = new Imagick(); 
$draw = new ImagickDraw(); 
  
// Fill the color in image 
$draw->setFillColor(new ImagickPixel('green')); 
  
// Set the text font size 
$draw->setFontSize(50); 
  
$metrix = $im->queryFontMetrics($draw, $string); 
$draw->annotation(0, 40, $string); 
$im->newImage($metrix['textWidth'], $metrix['textHeight'], 
        new ImagickPixel('white')); 
  
// Draw the image         
$im->drawImage($draw); 
  
// Use displayImage function 
$im->displayImage('servername'); 
  
$im->setImageFormat('png'); 
  
header("Content-Type: image/jpg"); 
  
// Display the output image 
echo $im->getImageBlob(); 
?> 


Output:
imagick::displayImages

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

RELATED ARTICLES

Most Popular

Dominic
32514 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6892 POSTS0 COMMENTS
Nicole Veronica
12012 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12107 POSTS0 COMMENTS
Shaida Kate Naidoo
7016 POSTS0 COMMENTS
Ted Musemwa
7262 POSTS0 COMMENTS
Thapelo Manthata
6975 POSTS0 COMMENTS
Umr Jansen
6963 POSTS0 COMMENTS