VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: idor on November 27, 2023, 14:08:02 PM

Title: Categy Page: imagecreatetruecolor(): Argument #1 ($width) must be greater than 0
Post by: idor on November 27, 2023, 14:08:02 PM
Hi everyone!

After updating from Joomla 3 to 4 and Virtuemart 4.2 when I try to access a category without a photo or trying to create a new one, in backend I get this error

An error has occurred.

    0 imagecreatetruecolor(): Argument #1 ($width) must be greater than 0

#    Function    Location
1    ()    JROOT/administrator/components/com_virtuemart/helpers/img2thumb.php:369
2    imagecreatetruecolor()    JROOT/administrator/components/com_virtuemart/helpers/img2thumb.php:369
3    Img2Thumb->NewImgResize()    JROOT/administrator/components/com_virtuemart/helpers/img2thumb.php:150
4    Img2Thumb->NewImgCreate()    JROOT/administrator/components/com_virtuemart/helpers/img2thumb.php:102
5    Img2Thumb->__construct()    JROOT/administrator/components/com_virtuemart/helpers/image.php:184
6    VmImage->createThumb()    JROOT/administrator/components/com_virtuemart/helpers/mediahandler.php:657
7    VmMediaHandler->displayMediaThumb()    JROOT/administrator/templates/vmadmin/html/com_virtuemart/sublayouts/images.php:291
8    include()    JROOT/administrator/templates/vmadmin/html/com_virtuemart/helpers/adminsublayouts.php:64
9    adminSublayouts::renderAdminVmSubLayout()    JROOT/administrator/templates/vmadmin/html/com_virtuemart/helpers/vmuikit_mediahandler.php:60
10    VmuikitMediaHandler::displayFilesHandler()    JROOT/administrator/templates/vmadmin/html/com_virtuemart/category/edit_images.php:40
11    include()    JROOT/libraries/src/MVC/View/HtmlView.php:415
12    Joomla\CMS\MVC\View\HtmlView->loadTemplate()    JROOT/administrator/templates/vmadmin/html/com_virtuemart/sublayouts/buildtabs.php:63
13    include()    JROOT/administrator/templates/vmadmin/html/com_virtuemart/helpers/adminsublayouts.php:64
14    adminSublayouts::renderAdminVmSubLayout()    JROOT/administrator/templates/vmadmin/html/com_virtuemart/helpers/vmuikit_adminuihelper.php:250
15    vmuikitAdminUIHelper::buildTabs()    JROOT/administrator/templates/vmadmin/html/com_virtuemart/category/edit.php:33
16    include()    JROOT/libraries/src/MVC/View/HtmlView.php:415
17    Joomla\CMS\MVC\View\HtmlView->loadTemplate()    JROOT/administrator/components/com_virtuemart/helpers/vmviewadmin.php:78
18    VmViewAdmin->display()    JROOT/administrator/components/com_virtuemart/views/category/view.html.php:136
19    VirtuemartViewCategory->display()    JROOT/administrator/components/com_virtuemart/helpers/vmcontroller.php:126
20    VmController->display()    JROOT/administrator/components/com_virtuemart/helpers/vmcontroller.php:151
21    VmController->edit()    JROOT/libraries/src/MVC/Controller/BaseController.php:693
22    Joomla\CMS\MVC\Controller\BaseController->execute()    JROOT/administrator/components/com_virtuemart/virtuemart.php:77
23    require_once()    JROOT/libraries/src/Dispatcher/LegacyComponentDispatcher.php:71
24    Joomla\CMS\Dispatcher\LegacyComponentDispatcher::Joomla\CMS\Dispatcher\{closure}()    JROOT/libraries/src/Dispatcher/LegacyComponentDispatcher.php:73
25    Joomla\CMS\Dispatcher\LegacyComponentDispatcher->dispatch()    JROOT/libraries/src/Component/ComponentHelper.php:361
26    Joomla\CMS\Component\ComponentHelper::renderComponent()    JROOT/libraries/src/Application/AdministratorApplication.php:143
27    Joomla\CMS\Application\AdministratorApplication->dispatch()    JROOT/libraries/src/Application/AdministratorApplication.php:186
28    Joomla\CMS\Application\AdministratorApplication->doExecute()    JROOT/libraries/src/Application/CMSApplication.php:293
29    Joomla\CMS\Application\CMSApplication->execute()    JROOT/administrator/includes/app.php:61
30    require_once()    JROOT/administrator/index.php:32

Any help?
Thank you in advance!
Title: Re: Categy Page: imagecreatetruecolor(): Argument #1 ($width) must be greater than 0
Post by: Jumbo! on November 28, 2023, 06:45:25 AM
Add valid "Thumbnail Image Width" and "Thumbnail Image Height" in VirtueMart Configuration under the Templates tab. They must be greater than zero.
Title: Re: Categy Page: imagecreatetruecolor(): Argument #1 ($width) must be greater than 0
Post by: idor on November 28, 2023, 09:23:14 AM
Hi I really appreciate your help!
At the beginning when I upgrated, I had this error in every category page in frontend and changing this indeed helped and don´t get this error in EVERY page..
but now I get this error whenever I call a category calling SUBcategories that have no image or when I try to create a new category.

I use PHP 8.1 although 8.2 doesn´t make any change. Which version is it better to use?
Title: Re: Categy Page: imagecreatetruecolor(): Argument #1 ($width) must be greater than 0
Post by: idor on November 29, 2023, 12:16:46 PM
I noticed that the error has gone if Enable Dynamic Thumbnail Resizing is set to NO.