您的位置:首页 > 文旅 > 美景 > 成都app拉新工作室加盟_网页制作免费网站_百度灰色关键词代做_百度seo优化排名

成都app拉新工作室加盟_网页制作免费网站_百度灰色关键词代做_百度seo优化排名

2025/2/8 12:43:55 来源:https://blog.csdn.net/lyb8010/article/details/145499124  浏览:    关键词:成都app拉新工作室加盟_网页制作免费网站_百度灰色关键词代做_百度seo优化排名
成都app拉新工作室加盟_网页制作免费网站_百度灰色关键词代做_百度seo优化排名

1、basic_data.sql

数据表:t_preference中的('osclass', 'allowedExt', 'png,gif,jpg,jpeg', 'STRING'),添加:'png,gif,jpg,jpeg,webp'

2、includes/osclass/mimes.php

'webp' => 'image/webp',

3、includes/osclass/classes/ImageProcessing.php

修改private function __construct($imagePath) {}

switch (@$this->image_info['mime']) {case 'image/gif':$this->ext = 'gif';$this->mime = 'image/gif';break;case 'image/png':$this->ext = 'png';$this->mime = 'image/png';break;case 'image/webp': // 增加 WebP 处理$this->ext = 'webp';$this->mime = 'image/webp';break;default:$this->ext = 'jpg';$this->mime = 'image/jpeg';if (!$this->_use_imagick) {$bg = imagecreatetruecolor($this->_width, $this->_height);// 处理 PNG、WebP 透明背景if (in_array($this->ext, ['png', 'webp'])) {imagefill($bg, 0, 0, imagecolorallocatealpha($bg, 0, 0, 0, 127));imagesavealpha($bg, true);imagealphablending($bg, false);} else {imagefill($bg, 0, 0, $this->imageColor($bg));imagesavealpha($bg, true);imagealphablending($bg, true);}imagecopy($bg, $this->im, 0, 0, 0, 0, $this->_width, $this->_height);imagedestroy($this->im);$this->im = $bg;}break;}

4、savetofile改成

public function saveToFile($imagePath, $ext = null) {if (file_exists($imagePath) && !is_writable($imagePath)) {throw new RuntimeException("$imagePath is not writable!");}if ($ext == null) {$ext = $this->ext;}// 允许 webp 格式if (!in_array($ext, ['png', 'gif', 'webp'])) {$ext = 'jpeg'; // 默认 jpeg}//var_dump($ext);if ($this->_use_imagick) {if ($ext === 'jpeg' && ($this->ext !== 'jpeg' && $this->ext !== 'jpg')) {$bg = new Imagick();$bg->newImage($this->_width, $this->_height, osc_canvas_background());$this->im->thumbnailImage($this->_width, $this->_height, true);$bg->compositeImage($this->im, Imagick::COMPOSITE_OVER, 0, 0);$this->im = $bg;$this->ext = 'jpeg';}$this->im->setImageDepth(8);$this->im->setImageFilename($imagePath);$this->im->setImageFormat($ext);$this->im->writeImage($imagePath);} else {switch ($ext) {case 'gif':imagegif($this->im, $imagePath);break;case 'png':imagepng($this->im, $imagePath, 0);break;case 'webp': // 增加 WebP 处理if (function_exists('imagewebp')) {//var_dump($ext);var_dump('oka');die;imagewebp($this->im, $imagePath);} else {//var_dump($ext);var_dump('okb');die;throw new RuntimeException("WebP format is not supported by GD");}break;default:if (($ext === 'jpeg' && ($this->ext !== 'jpeg' && $this->ext !== 'jpg')) || $this->_watermarked) {$this->ext = 'jpeg';}imagejpeg($this->im, $imagePath);break;}}}

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com