Open In App

PHP | Imagick displayImages() Function

Last Updated : 24 Oct, 2019
Comments
Improve
Suggest changes
Like Article
Like
Report
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
<?php 

// Create an Imagick object 
$imagick = new Imagick( 
'https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-9.png'); 

// Use displayImage function 
$imagick->displayImage('servername'); 

header("Content-Type: image/jpg"); 

// Display the output image 
echo $imagick->getImageBlob(); 
?> 
Output: imagick::displayImages Program 2: php
<?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

Next Article

Similar Reads