多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
```php /** * 图片压缩 * * @param [type] $filename * @return void */ function zlib($filename) { $ext = substr(strrchr($filename, '.'), 1); if ($ext == 'png' || $ext == 'jpg' || $ext == 'jpeg' || $ext == 'bmp' || $ext == 'gif') { ini_set("memory_limit", "256M"); //修改php分配的内存 $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 = imagecreatefromstring(file_get_contents($filename)); imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height); // 输出 imagejpeg($image_p, $filename, 70); } } ```