TP6部署到PHP8.2版本的服务器上,涉及到图片处理的时候会报如下错误:
Implicit conversion from float 477.75 to int loses precision[/********/vendor/topthink/think-image/src/Image.php:270]"
打开Image.php找到如下方法:
/**
* 裁剪图像
*
* @param integer $w 裁剪区域宽度
* @param integer $h 裁剪区域高度
* @param integer $x 裁剪区域x坐标
* @param integer $y 裁剪区域y坐标
* @param integer $width 图像保存宽度
* @param integer $height 图像保存高度
*
* @return $this
*/
public function crop($w, $h, $x = 0, $y = 0, $width = null, $height = null)
{
//设置保存尺寸
empty($width) && $width = $w;
empty($height) && $height = $h;
do {
//创建新图像
$img = imagecreatetruecolor($width, $height);
// 调整默认颜色
$color = imagecolorallocate($img, 255, 255, 255);
imagefill($img, 0, 0, $color);
//裁剪
imagecopyresampled($img, $this->im, 0, 0, (int)$x, $y, $width, $height, (int)$w, $h);
imagedestroy($this->im); //销毁原图
//设置新图像
$this->im = $img;
} while (!empty($this->gif) && $this->gifNext());
$this->info['width'] = (int) $width;
$this->info['height'] = (int) $height;
return $this;
}
加粗的这一行,在参数前面加上 (int)强制转换一下就好了。
vue2 Implicit conversion from float int loses precision php8Implicit Mysql8新增用户,mysql8配置权限,mysql8配置,mysql8配置文件 Linux命令,scp,scp命令,Linux复制 git commit git add centos git 搭建FTP,Linux FTP,禁止FTP登录ssh 上传文件,阿里云OSS上传,文件上传到OSS,OSS文件上传,OSS上传 微信支付,微信支付V3,PHP微信支付,微信nativePay支付,微信jsapi支付 微信支付,微信支付V3,PHP微信支付 bootstrap4 modal, lavarel The subversion command line tools are no longer provided by Xcode. 银联支付,tp5.1银联支付 支付宝即时到账,PHP支付宝 system libzip must be upgraded to version >= 0.11 CMake 3.0.2 or higher is required