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
32726 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
7104 POSTS0 COMMENTS
Nicole Veronica
12241 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12328 POSTS0 COMMENTS
Shaida Kate Naidoo
7219 POSTS0 COMMENTS
Ted Musemwa
7477 POSTS0 COMMENTS
Thapelo Manthata
7200 POSTS0 COMMENTS
Umr Jansen
7176 POSTS0 COMMENTS