简体   繁体   中英

How to save jpeg image as Progressive JPEG?

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

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 :

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);

  }
 }

try like below

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

may be issue with type casting

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM