我有以下功能将 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);
}
}
这就是我调用 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);
}
}