Wednesday, June 10, 2026
HomeLanguagesPHP | imageinterlace() Function

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
  
// Create an image from URL
$im = imagecreatefrompng(
  
// Enable interlacing
imageinterlace($im, 1);
  
// View the output
header('Content-type: image/jpeg');
imagejpeg($im);
imagedestroy($im);
?>


Output:

Program 2: In this example we will disable interlacing.




<?php
  
// Create an image from URL
$im = imagecreatefrompng(
  
// Disable interlacing
imageinterlace($im, 0);
  
// View the output
header('Content-type: image/jpeg');
imagejpeg($im);
imagedestroy($im);
?>


Output:

Reference: https://www.php.net/manual/en/function.imageinterlace.php

RELATED ARTICLES

Most Popular

Dominic
32515 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6896 POSTS0 COMMENTS
Nicole Veronica
12012 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12109 POSTS0 COMMENTS
Shaida Kate Naidoo
7018 POSTS0 COMMENTS
Ted Musemwa
7262 POSTS0 COMMENTS
Thapelo Manthata
6976 POSTS0 COMMENTS
Umr Jansen
6963 POSTS0 COMMENTS