Tuesday, October 7, 2025
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
32340 POSTS0 COMMENTS
Milvus
86 POSTS0 COMMENTS
Nango Kala
6708 POSTS0 COMMENTS
Nicole Veronica
11872 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11936 POSTS0 COMMENTS
Shaida Kate Naidoo
6829 POSTS0 COMMENTS
Ted Musemwa
7090 POSTS0 COMMENTS
Thapelo Manthata
6780 POSTS0 COMMENTS
Umr Jansen
6784 POSTS0 COMMENTS