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

PHP 8.1 TypeError: imagecopymerge(): Argument #9 ($pct) must be of type int in GD when custom watermark image is applied #3727

Closed
Tomasz-Silpion opened this issue Jan 9, 2024 · 1 comment · Fixed by #3736
Labels

Comments

@Tomasz-Silpion
Copy link
Contributor

Preconditions (*)

  1. PHP 8.1 or newer.
  2. Main branch or any recent version of OpenMage.

Steps to reproduce (*)

  1. Go to System -> Configuration -> Product Image Watermarks.
  2. Add watermark images and set every opacity field to any value.

Expected result (*)

Watermark is properly applied to the product image.

Actual result (*)

TypeError: imagecopymerge(): Argument #9 ($pct) must be of type int, string given exception is thrown in lib/Varien/Image/Adapter/Gd2.php:504

@kiatng
Copy link
Contributor

kiatng commented Jan 10, 2024

I had the exact same thing a week ago:

Uncaught TypeError: imagecopymerge(): Argument #9 ($pct) must be of type int, string given in .../lib/Varien/Image/Adapter/Gd2.php:570
Posted 7 days ago. Visible to the public. Linked content.
Uncaught TypeError: imagecopymerge(): Argument #9 ($pct) must be of type int, string given in /.../lib/Varien/Image/Adapter/Gd2.php:570
Stack trace:
#0 /.../lib/Varien/Image/Adapter/Gd2.php(570): imagecopymerge(Object(GdImage), Object(GdImage), 0, 0, 0, 0, 400, 400, '')
#1 /.../lib/Varien/Image.php(197): Varien_Image_Adapter_Gd2->watermark('/home/web/publi...', 0, 0, 30, false)
#2 /.../app/code/core/Mage/Catalog/Model/Product/Image.php(557): Varien_Image->watermark('/home/web/publi...')
#3 /.../app/code/core/Mage/Catalog/Helper/Image.php(362): Mage_Catalog_Model_Product_Image->setWatermark('default/images_...')
#4 /.../app/design/frontend/.../default/template/page/html/head.phtml(73): Mage_Catalog_Helper_Image->__toString()

Set the product watermark opacity to some integer value:

fballiano pushed a commit that referenced this issue Feb 2, 2024
…fixes #3727 (#3736)

* Added helper methods to cast getStoreConfig to int or float

* Use Mage::getStoreConfigFlag()

---------

Co-authored-by: Ng Kiat Siong <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants