Friday, October 10, 2025
HomeLanguagesPHP | Imagick setImageFormat() Function

PHP | Imagick setImageFormat() Function

The Imagick::setImageFormat() function is an inbuilt function in PHP which is used to set the format of a particular image in a sequence.
Syntax: 
 

bool Imagick::setImageFormat( string $format )

Parameters: This function accepts a single parameter $format which holds a string value of the image format like png, svg, etc. Format support is totally depends on the installation of the imagick.
Return Value: This function returns TRUE on success.
Below programs illustrate the Imagick::setImageFormat() function in PHP:
Program 1: 
 

php




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


Output: 
 

png

Program 2: 
 

php




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


Output: 
 

jpeg

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

RELATED ARTICLES

Most Popular

Dominic
32350 POSTS0 COMMENTS
Milvus
87 POSTS0 COMMENTS
Nango Kala
6718 POSTS0 COMMENTS
Nicole Veronica
11880 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11941 POSTS0 COMMENTS
Shaida Kate Naidoo
6838 POSTS0 COMMENTS
Ted Musemwa
7099 POSTS0 COMMENTS
Thapelo Manthata
6794 POSTS0 COMMENTS
Umr Jansen
6794 POSTS0 COMMENTS