Convert an image from progressive to interlaced without losing quality or details?

3.2k Views Asked by At

I'm trying to retrieve large images from a directory outside of the root directory. At the moment I just use "fpassthru", but this loads the image either progressively or interlaced depending on what is was when uploaded.

How do I create a complete copy of an image but convert it to interlaced without losing any quality or detail with PHP?

1

There are 1 best solutions below

3
On BEST ANSWER

If you use the GD libraries that come with PHP, you can use imageinterlace to accomplish this.

Here's from the example:

<?php
// Create an image instance
$im = imagecreatefromgif('php.gif');

// Enable interlancing
imageinterlace($im, true);

// Save the interlaced image
imagegif($im, './php_interlaced.gif');
imagedestroy($im);
?>

Alternately, you could use ImageMagick.