Tuesday, November 19, 2024
Google search engine
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

Recent Comments