Open In App

PHP | Imagick setFormat() Function

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

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

// Set the Format
$imagick->setFormat('png');

// Get the Format
$format = $imagick->getFormat();

echo $format;
?>
Output:
png
Program 2: php
<?php

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

// 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

Next Article

Similar Reads