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)

I just upgraded a system to 3.57 (I know, I'm a little late to the party).  After doing so, I went to upload a logo for them that was in GIF format.  After selecting the file and clicking on Upload, I received the following error:

imagecolorsforindex(): Argument #2 ($color) is out of range in /home/folder/public_html/cmsAdmin/lib/image_functions.php on line 152.

Rather than trying to diagose the issue, I simply saved it as a JPG and the upload was fine.  I have to say, we have not had a gif in years, so I'm not sure if it just started happening or not.  It could be mere coincidence.

I just wanted to report it in case there was something anyone know about it.

We are using PHP 8.1 on this site.

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