imageinterlace 


gd apg

ENABLE or DISABLE the interlace.





INTERLACING

also known as INTERLEAVING, is a bitmap-type method of encoding images, allowing the image to be gradually received until it is completed.

If the interlace bit is set and the image is used as a JPEG image, the image is created as a progressive JPEG.

If $enable ≠ 0 the image will be interlaced.

If $enable = 0 the interlace bit is turned off.


This function returns 1 if the interlace bit is set for the image, 0 otherwise.



<?php

int imageinterlace 
( GdImage $image, ?bool $enable = null )


where,

$image = The image identifier

$enable 
= To control if interlace will be used or not

?>
 

  $image   


The image identifier.



  $enable   


To control if interlace will be used or not.

IMAGE FORMAT POSSIBLE LOADING ORDERS
GIF 0, 8, 16, ..., (8n+4)
 2, 6, 10, 14, ..., (4n+2)
1, 3, 5, 7, 9, ..., (2n+1)
PNG Adam7 algorithm
adam7 app
(Image from Wikipedia)
JPEG Does not make use of pixel interlacing,
instead uses a sequence based on frequency decomposition.
ed48


  1 EXERCISE   

<?php

echo 'PHP VERSION: ' . PHP_VERSION . '<br><br>';

// $lang = 'pt';
$lang = 'en';

$org_file01 = "gif/GIF 024 01.gif";

$des_file01 = "gif/GIF 024 01 imageinterlace.gif";

$ctrl01 = 2;

echo 
$org_file01; ?><br><br>
<img src="<?php echo $org_file01; ?>"
alt="<?php echo $org_file01; ?>"
title="<?php echo $org_file01; ?>" width="400"><br><br>

<?php
$id_camel01 
= imagecreatefromgif( $org_file01);

$interlaced01 = imageinterlace($id_camel01, $ctrl01);

if(
$interlaced01 == true)
{
imagegif($id_camel01, $des_file01);

$pt = 'IMAGEM ENTRELAÇADA';
$en = 'INTERLACED IMAGE';

echo 
$des_file01
. '<br>' . $$lang; ?><br><br>
<img src="<?php echo $des_file01; ?>"
alt="<?php echo $des_file01; ?>" 
title="<?php echo $des_file01; ?>" width="400">
<?php
}
else
{
$pt = 'Imagem não pode ser entrelaçada!';
$en = 'Image can not be interlaced!';
echo $
$lang;
}

?> 

 RESULT   

GIF 024 01.gif

EXISTING IMAGE

GIF 024 01.gif apr

GIF 024 01 imageinterlace.gif

INTERLACED gif IMAGE

GIF 024 01 imageinterlace.gif apr

  2 EXERCISE   

<?php

echo 'PHP VERSION: ' . PHP_VERSION . '<br><br>';

// $lang = 'pt';
$lang = 'en';

$org_file02 = "png/PNG 075 02.png";

$des_file02 = "png/PNG 075 02 imageinterlace.png";

$ctrl02 = 8;

echo 
$org_file02; ?><br><br>
<img src="<?php echo $org_file02; ?>"
alt="<?php echo $org_file02; ?>"
title="<?php echo $org_file02; ?>" width="400"><br><br>

<?php
$id_camel02 
= imagecreatefrompng( $org_file02);

$interlaced02 = imageinterlace($id_camel02, $ctrl02);

if(
$interlaced02 == true)
{
imagepng($id_camel02, $des_file02);

$pt = 'IMAGEM ENTRELAÇADA';
$en = 'INTERLACED IMAGE';

echo 
$des_file02
. '<br>' . $$lang; ?><br><br>
<img src="<?php echo $des_file02; ?>"
alt="<?php echo $des_file02; ?>" 
title="<?php echo $des_file02; ?>" width="400">
<?php
}
else
{
$pt = 'Imagem não pode ser entrelaçada!';
$en = 'Image can not be interlaced!';
echo $
$lang;
}

?> 

 RESULT   

PNG 075 02.png

EXISTING IMAGE

PNG 075 02.png apr

PNG 075 02 imageinterlace.png

INTERLACED png IMAGE

PNG 075 02 imageinterlace.png apr

  3 EXERCISE   

<?php

echo 'PHP VERSION: ' . PHP_VERSION . '<br><br>';

// $lang = 'pt';
$lang = 'en';

$org_file03 = "jpeg/JPEG 034 03.jpg";

$des_file03 = "jpeg/JPEG 034 03 imageinterlace.jpg";

$ctrl03 = 5;

echo 
$org_file03; ?><br><br>
<img src="<?php echo $org_file03; ?>"
alt="<?php echo $org_file03; ?>"
title="<?php echo $org_file03; ?>" width="400"><br><br>

<?php
$id_camel03 
= imagecreatefromjpeg($org_file03);

$interlaced03 = 
imageinterlace($id_camel03, $ctrl03);

if(
$interlaced03 == true)
{
imagejpeg($id_camel03, $des_file03);

$pt = 'IMAGEM ENTRELAÇADA';
$en = 'INTERLACED IMAGE';

echo 
$des_file03
. '<br>' . $$lang; ?><br><br>
<img src="<?php echo $des_file03; ?>"
alt="<?php echo $des_file03; ?>" 
title="<?php echo $des_file03; ?>" width="400">
<?php
}
else
{
$pt = 'Imagem não pode ser entrelaçada!';
$en = 'Image can not be interlaced!';
echo $
$lang;
}

?> 

 RESULT   

JPEG 034 03.jpg

EXISTING IMAGE

JPEG 034 03.jpg apr

JPEG 034 03 imageinterlace.jpg

INTERLACED jpg IMAGE

JPEG 034 03 imageinterlace.jpg apr