Open In App

PHP | Imagick setInterlaceScheme() Function

Last Updated : 07 Mar, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

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
  
// Create a new imagick object
$imagick = new Imagick(
  
// Set the interlace scheme
$imagick->setInterlaceScheme(Imagick::INTERLACE_PLANE);
  
// Get the interlace scheme
$interlace_scheme = $imagick->getInterlaceScheme();
echo $interlace_scheme;
?>


Output:

3

Program 2:




<?php
  
// Create a new imagick object
$imagick = new Imagick(
  
// Set the interlace scheme to be used in
// compression to imagick::INTERLACE_LINE
$imagick->setInterlaceScheme(Imagick::INTERLACE_LINE);
  
// Set the quality of the compression
$imagick->setImageCompressionQuality(1);
  
// Show the output
$imagick->setImageFormat('jpg');
header("Content-Type: image/jpg");
echo $imagick->getImageBlob();
?>


Output:



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads