think-image
think-image copied to clipboard
大佬, php8出现数据转换的精度问题了, 能修复一下吗?
大佬, php8出现数据转换的精度问题了, 能修复一下吗? Implicit conversion from float 28.083582089552237 to int loses precision #0 [internal function]: think\initializer\Error->appError(8192, 'Implicit conver...', '...', 359) #1 \vendor\topthink\think-image\src\Image.php(359): imagecopyresampled(Object(GdImage), Object(GdImage), 0.0, 28.083582089552, 0, 0, 128.0, 71.832835820896, 670, 376) #2 \app\service\FileUpload.php(91): think\Image->thumb(128, 128, 2)
同样问题,2023-07-16 还在
同样问题,2023-07-16 还在
其实已经修复了, 是大佬忘记发版本, 你把composer.json里的版本号改成"dev-master"试试
改完记得composer update
2023-12-27 日复现,回退到8.0 版本正常
php 8.1下丢失精度修复src/Image.php文件修改imagecopyresampled
do {
//创建新图像
$img = imagecreatetruecolor($width, $height);
// 调整默认颜色
$color = imagecolorallocate($img, 255, 255, 255);
imagefill($img, 0, 0, $color);
//裁剪
imagecopyresampled($img, $this->im, intval($posx), intval($posy), intval($x), intval($y), intval($neww), intval($newh), intval($w), intval($h));
imagedestroy($this->im); //销毁原图
$this->im = $img;
} while (!empty($this->gif) && $this->gifNext());
同样问题,2024-04-29 还在。php版本8.1
同样问题,2024-04-29 还在。php版本8.1
你试试把版本号改成dev-master, 然后update一下, 如果还不行就换别的用吧
2024-07-17 ps: 问题还在,dev-master也不行 解决办法:374 行改为 return $this->crop($w, $h, $x, $y, (int) $width, (int) $height); 等大佬更新吧~
@justin-xean 可以使用:https://packagist.org/packages/intervention/image
进行重构。。