PHP | Imagick setInterlaceScheme() Function
Last Updated :
07 Mar, 2024
The Imagick::setInterlaceScheme() function is an inbuilt function in PHP which is used to set the interlace scheme which is later used in the image compression. There are different interlacing schemes available as given below which can be used to achieve the compression.
Syntax:
bool Imagick::setInterlaceScheme( int $interlace_scheme )
Parameters: This function accepts a single parameter $interlace_scheme which holds the integer value corresponding to one of INTERLACE constants.
List of all INTERLACE constants are given below:
- imagick::INTERLACE_UNDEFINED (0)
- imagick::INTERLACE_NO (1)
- imagick::INTERLACE_LINE (2)
- imagick::INTERLACE_PLANE (3)
- imagick::INTERLACE_PARTITION (4)
- imagick::INTERLACE_GIF (5)
- imagick::INTERLACE_JPEG (6)
- imagick::INTERLACE_PNG (7)
Return Value: This function returns TRUE on success.
Exceptions: This function throws ImagickException on error.
Below programs illustrate the Imagick::setInterlaceScheme() function in PHP:
Program 1:
<?php
$imagick = new Imagick(
$imagick ->setInterlaceScheme(Imagick::INTERLACE_PLANE);
$interlace_scheme = $imagick ->getInterlaceScheme();
echo $interlace_scheme ;
?>
|
Output:
3
Program 2:
<?php
$imagick = new Imagick(
$imagick ->setInterlaceScheme(Imagick::INTERLACE_LINE);
$imagick ->setImageCompressionQuality(1);
$imagick ->setImageFormat( 'jpg' );
header( "Content-Type: image/jpg" );
echo $imagick ->getImageBlob();
?>
|
Output:
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...