如何将jpeg图像保存为Progressive JPEG?

时间:2021-07-11 19:13:27

I have below function to save JPEG as Progressive JPEG. It saved, but not as progressive JPEG. Is this correct ?

我有以下功能将JPEG保存为渐进式JPEG。它保存了,但不是渐进的JPEG。它是否正确 ?

function save($filename, $image_type = IMAGETYPE_JPEG, $compression = 75, $permissions = null) {

    if ($image_type == IMAGETYPE_JPEG) {

        imageinterlace($this->image, true); //convert to progressive ?
        imagejpeg($this->image, $filename, $compression);

    } elseif ($image_type == IMAGETYPE_GIF) {

        imagegif($this->image, $filename);

    } elseif ($image_type == IMAGETYPE_PNG) {

        imagepng($this->image, $filename);
    }

    if ($permissions != null) {

        chmod($filename, $permissions);
    }
}

This is how i called save() function :

这就是我所谓的save()函数:

function img_reconstruct($saveto) {
  $image = new SimpleImage();

  $image->load($saveto);

  list($width, $height) = getimagesize($saveto);

  if ($width > 800 && $width < 1200) {

    $image->resize(800, $height);

    $image->save($saveto);

  }
 }

1 个解决方案

#1


4  

try like below

尝试如下

imageinterlace($this->image, 1); //convert to progressive ?

may be issue with type casting

可能是类型转换的问题

#1


4  

try like below

尝试如下

imageinterlace($this->image, 1); //convert to progressive ?

may be issue with type casting

可能是类型转换的问题