Fixed ErrorException: [E_DEPRECATED] Implicit conversion from float 47.5 to int loses precision in src\XF\Image\Gd.php at line 104


Well-known member
Affected version
v2.2.8 Patch 1
I don't know if this bug report has been reported, but today I am getting such an error in the resource manager for the operation I have done on localhost.
PHP version: 8.1.2
#0 [internal function]: XF::handlePhpError(8192, '[E_DEPRECATED] ...', 'C:\\xampp\\htdocs...', 104)
#1 src\XF\Image\Gd.php(104): imagecopyresampled(Object(GdImage), Object(GdImage), 0, 0, 47.5, 0, 96, 96, 45, 45)
#2 src\XF\Image\AbstractDriver.php(131): XF\Image\Gd->crop(96, 96, 47.5, 0, 45, 45)
#3 src\addons\XFRM\Service\ResourceItem\Icon.php(140): XF\Image\AbstractDriver->resizeAndCrop(96)
#4 src\addons\XFRM\ControllerPlugin\ResourceIcon.php(31): XFRM\Service\ResourceItem\Icon->updateIcon()
#5 src\addons\XFRM\Pub\Controller\Category.php(278): XFRM\ControllerPlugin\ResourceIcon->actionUpload(Object(XFRM\Entity\ResourceItem))
#6 src\XF\Mvc\Dispatcher.php(352): XFRM\Pub\Controller\Category->actionAdd(Object(XF\Mvc\ParameterBag))
#7 src\XF\Mvc\Dispatcher.php(259): XF\Mvc\Dispatcher->dispatchClass('XFRM:Category', 'Add', Object(XF\Mvc\RouteMatch), Object(XFRM\Pub\Controller\Category), NULL)
#8 src\XF\Mvc\Dispatcher.php(115): XF\Mvc\Dispatcher->dispatchFromMatch(Object(XF\Mvc\RouteMatch), Object(XFRM\Pub\Controller\Category), NULL)
#9 src\XF\Mvc\Dispatcher.php(57): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
#10 src\XF\App.php(2351): XF\Mvc\Dispatcher->run()
#11 src\XF.php(517): XF\App->run()
#12 index.php(20): XF::runApp('XF\\Pub\\App')
#13 {main}

XF Bug Bot

XenForo bug fixer bot
Staff member
Thank you for reporting this issue, it has now been resolved. We are aiming to include any changes that have been made in a future XF release (2.2.9).

Change log:
Improve PHP 8.1 compatibility when resizing and cropping an image
There may be a delay before changes are rolled out to the XenForo Community.