PHP GD压缩图片

public function zip_pic(){
        ini_set("memory_limit","256M"); //修改php分配的内存
        $filename = './images/imgp0627.jpg';
        $percent = 1;
         
        // 内容类型
        header('Content-Type: image/jpeg');
         
        // 获取新的尺寸
         
        list($width, $height) = getimagesize($filename);
        $new_width = $width ;//* $percent;
        $new_height = $height ;//* $percent;
         
        // 重新取样
        $image_p = imagecreatetruecolor($new_width, $new_height);
        $image = imagecreatefromjpeg($filename);
        imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
         
        // 输出
        imagejpeg($image_p, './images/imgp0627-2.jpg', 70);
         
    }

 

posted on 2016-05-09 15:51  岩_生  阅读(689)  评论(0编辑  收藏  举报

导航