PHP | imageinterlace() Function
The imageinterlace() function is an inbuilt function in PHP which is used to enable or disable interlace in an image. Interlacing (also known as interleaving) is a method of encoding a bitmap image such that a person who has partially received it sees a degraded copy of the entire image. One difference between interlaced and non-interlaced images on a website is that the former one is loaded in a low-quality version first and then it’s quality keeps improving as the website loads whereas a non-interlaced image is loaded in a fixed quality line by line from top to bottom when the website loads.
Syntax:
int imageinterlace( resource $image, int $interlace )
Parameters: This function accepts two parameters as mentioned above and described below:
- $image: It specifies the image to be interlaced.
- $interlace: It specifies whether to enable or disable interlacing.
Return Value: This function returns 1 if the interlace bit is set for the image, otherwise 0.
Below examples illustrate the imageinterlace() function in PHP:
Program 1: In this example we will enable interlacing.
<?php
$im = imagecreatefrompng(
imageinterlace( $im , 1);
header( 'Content-type: image/jpeg' );
imagejpeg( $im );
imagedestroy( $im );
?>
|
Output:
Program 2: In this example we will disable interlacing.
<?php
$im = imagecreatefrompng(
imageinterlace( $im , 0);
header( 'Content-type: image/jpeg' );
imagejpeg( $im );
imagedestroy( $im );
?>
|
Output:
Reference: https://www.php.net/manual/en/function.imageinterlace.php
Last Updated :
30 Jan, 2020
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...