phpimageconvertersprogressive

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


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?


Solution

  • 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.