Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

大佬, php8出现数据转换的精度问题了, 能修复一下吗? #22

Open
zjkal opened this issue Sep 2, 2022 · 8 comments
Open

Comments

@zjkal
Copy link
Contributor

zjkal commented Sep 2, 2022

大佬, 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)

@lindaoling
Copy link

同样问题,2023-07-16 还在

@zjkal
Copy link
Contributor Author

zjkal commented Jul 16, 2023

同样问题,2023-07-16 还在

其实已经修复了, 是大佬忘记发版本, 你把composer.json里的版本号改成"dev-master"试试

改完记得composer update

@XiaoshengSu
Copy link

XiaoshengSu commented Dec 27, 2023

2023-12-27 日复现,回退到8.0 版本正常

@gsmdenis
Copy link

gsmdenis commented Feb 9, 2024

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());

@TTC1002335644
Copy link

同样问题,2024-04-29 还在。php版本8.1

@zjkal
Copy link
Contributor Author

zjkal commented May 4, 2024

同样问题,2024-04-29 还在。php版本8.1

你试试把版本号改成dev-master, 然后update一下, 如果还不行就换别的用吧

@justin-xean
Copy link

2024-07-17
ps: 问题还在,dev-master也不行
解决办法:374 行改为 return $this->crop($w, $h, $x, $y, (int) $width, (int) $height); 等大佬更新吧~

@hulang
Copy link

hulang commented Aug 7, 2024

@justin-xean 可以使用:https://packagist.org/packages/intervention/image进行重构。。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants