I get the following error after uploading to 3.57 - imagecolorsforindex(): Argument #2 ($color) is out of range in lib/image_functions.php on line 152.

4 posts by 3 authors in: Forums > CMS Builder
Last Post: February 20, 2023   (RSS)

By Dave - February 13, 2023

Hi Gary, 

Thanks for the report.  It looks like this is a new issue introduced by PHP 8: 

From: https://www.php.net/manual/en/function.imagecolorsforindex.php

imagecolorsforindex() now throws a ValueError exception if color is out of range; previously, false was returned instead.

If you still have that GIF available could you email it to me at dave@interactivetools.com?  We'll try to reproduce the issue and add some code to workaround it.

Thanks!

Dave Edis - Senior Developer
interactivetools.com

Will do - thank you!

By Lucia - February 20, 2023

Hi Gary,

I've found a fix for this bug, which should be included in the next CMSB release version. If you'd like to patch it in the meantime, you can replace this line in cmsb/lib/image_functions.php (at/around line 152)

    $transparentColor = @imagecolorsforindex($sourceImage, $transparentIndex);

With this:

    $transparentColor = false;
    if ($transparentIndex >= 0) {
      $transparentColor = @imagecolorsforindex($sourceImage, $transparentIndex);
    }

Let me know if you have any further questions!

Thanks,

Lucia
Technical Lead
interactivetools.com