Open In App

PHP | Imagick setFormat() Function

Last Updated : 05 Dec, 2019
Improve
Improve
Like Article
Like
Save
Share
Report

The Imagick::setFormat() function is an inbuilt function in PHP which is used to set the format of the Imagick object.

Syntax:

bool Imagick::setFormat( string $format )

Parameters: This function accepts a single parameter $format which holds an string value.

Return Value: This function returns TRUE on success.

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

Program 1:




<?php
  
// Create a new imagick object
$imagick = new Imagick(
  
// Set the Format
$imagick->setFormat('png');
  
// Get the Format
$format = $imagick->getFormat();
  
echo $format;
?>


Output:

png

Program 2:




<?php
  
// Create a new imagick object
$imagick = new Imagick(
  
// Set the Format
$imagick->setFormat('jpeg');
  
// Get the Format
$format = $imagick->getFormat();
  
echo $format;
?>


Output:

jpeg

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


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads