3

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

  }
 }
Snoke
  • 73
  • 1
  • 6
  • Hi Snoke, did you get this working? I am also looking for converting the jpeg to progressive jpeg. – Suriyamoorthy Baskaran Apr 02 '13 at 09:55
  • Same here. Any idea why it might be not working, no matter if you use imageinterlace($this->image, true); or imageinterlace($this->image, 1); – Werner Dec 28 '14 at 17:06
  • Is jpeg format only gives the progressive images why not png format images? I have a doubt like I have seen all the blogs are talking about progressive jpegs only and not about any png format images. can someone clarify? – Siluveru Kiran Kumar Dec 17 '19 at 06:34

1 Answers1

4

try like below

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

may be issue with type casting

Saiyam Patel
  • 1,161
  • 9
  • 18