Convert JPEG to a Progressive JPEG in PHP

前端 未结 3 696
[愿得一人]
[愿得一人] 2021-01-06 04:47

I\'m trying to re-save an already created JPEG as a progressive jpg.

Basically, on the front end I have some JS that crops an image, and outputs a base64 im

相关标签:
3条回答
  • 2021-01-06 05:17

    Try Imagick (ImageMagic Package) as shown in here : http://php.net/manual/en/imagick.setinterlacescheme.php

    $image = new Imagick('image.jpg');
    
    $image->thumbnailImage(500, 0);
    
    $image->setInterlaceScheme(Imagick::INTERLACE_PLANE);
    
    $image->writeImage('progressive.jpg');
    
    0 讨论(0)
  • 2021-01-06 05:36

    Use imageinterlace.

    $src_img = imagecreatefromjpeg('source.jpg');
    
    imageinterlace($src_img, true);
    
    imagejpeg($src_img, 'destination.jpg');
    
    imagedestroy($src_img);
    
    0 讨论(0)
  • 2021-01-06 05:38

    Create image resource with imagecreatefromstring:

    $data = base64_decode($data);
    $im = imagecreatefromstring($data);
    if ($im === false) {
      die("imagecreatefromstring failed");
    }
    imageinterlace($im, true);
    imagejpeg($im, 'new.jpg');
    imagedestroy($im);
    
    0 讨论(0)
提交回复
热议问题