$color is out of range Topic is solved

Need help with the Administration of your Joomla! 4.x site? This is the spot for you.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10
Post Reply
jerry258
Joomla! Apprentice
Joomla! Apprentice
Posts: 49
Joined: Wed Jun 01, 2022 9:44 pm

$color is out of range

Post by jerry258 » Fri May 05, 2023 10:25 pm

This is one I couldn't find any posts on: imagecolorsforindex(): Argument #2 ($color) is out of range

How does one go about finding where this error occurs?
It prevents me from choosing any image to load.
Please help

User avatar
AMurray
Joomla! Exemplar
Joomla! Exemplar
Posts: 9739
Joined: Sat Feb 13, 2010 7:35 am
Location: Australia

Re: $color is out of range

Post by AMurray » Sat May 06, 2023 1:51 am

Don't think this is a Joomla issue - it's a PHP error.

https://www.php.net/manual/en/function. ... rindex.php

Perhaps some PHP guru can explain the techno-babble. :).
Regards - A Murray
General Support Moderator

User avatar
toivo
Joomla! Master
Joomla! Master
Posts: 17439
Joined: Thu Feb 15, 2007 5:48 am
Location: Sydney, Australia

Re: $color is out of range

Post by toivo » Sat May 06, 2023 2:41 am

Joomla 4.3 refers to the native PHP function imagecolorsforindex() twice, both times when processing images with transparency. The calls are in the functions Image::crop() and Image::resize() in libraries/src/Image/Image.php.
Those two functions are called from several Joomla core routines and probably also third party extensions, using the GD library.

Which version of PHP does this site use? This question is relevant because function imagecolorsforindex() changed slightly in PHP 8.

How did you create the images you are trying to load?

Change the Global Configuration so that the error messages identify the script and display also the PHP call stack so that it is possible to see the sequence of function calls:
  • Debug System: Yes
  • Error Reporting: Maximum
  • Log Almost Everything: Yes
Copy and paste the messages from the page to your reply. Alternatively, download the log file administrator/logs/everything.php and copy the relevant lines from there.
Toivo Talikka, Global Moderator

jerry258
Joomla! Apprentice
Joomla! Apprentice
Posts: 49
Joined: Wed Jun 01, 2022 9:44 pm

Re: $color is out of range

Post by jerry258 » Mon May 08, 2023 5:01 pm

Thanks Toivo. That error only happened when I turned on thumbnails in Filesystem Group>Local. I turned it off after and the error cleared. Turned it back on this morning to recreate the error, but it didn't show. I' keep trying and send you the data. I am on Joomla ver. 4.3.1, and php 8.1.17. I'll post again if I see the error again.

jerry258
Joomla! Apprentice
Joomla! Apprentice
Posts: 49
Joined: Wed Jun 01, 2022 9:44 pm

Re: $color is out of range

Post by jerry258 » Sat May 27, 2023 4:36 pm

Thanks again Toivo & AMurray
I am not fluent in php but the attached are what I think you want
You do not have the required permissions to view the files attached to this post.

User avatar
toivo
Joomla! Master
Joomla! Master
Posts: 17439
Joined: Thu Feb 15, 2007 5:48 am
Location: Sydney, Australia

Re: $color is out of range

Post by toivo » Sun May 28, 2023 12:05 am

It is not clear what triggers the PHP error 'Page not found'.

The other error comes from the following PHP code in libraries/src/Image/Image.php, line 716:

Code: Select all

            // Get the transparent color values for the current image.
            $rgba  = imagecolorsforindex($this->getHandle(), imagecolortransparent($this->getHandle()));
The second argument of the function imagecolorsforindex() above is the value returned by the function imagecolortransparent(), which in this case returns an invalid value of the transparent colour.

Ref. PHP: imagecolortransparent

Key Questions
jerry258 wrote:
Mon May 08, 2023 5:01 pm
That error only happened when I turned on thumbnails in Filesystem Group>Local.
Q1: Where or what exactly is Filesystem Group>Local? Is it a folder in the server or some option in a third party extension?
Q2: How were those images created, meaning which software application created them?

Additional Checks

Go to System - Information - System Information and click the tab PHP Information. Search for 'gd' on the page or locate 'fileinfo' and 'filter', under which you should see the heading 'gd'.

Is the library GD enabled?

What is the version of the GD library from the line starting with 'GD Version'?

If the heading 'gd' is not there or if the line 'GD Support' shows that the GD library is disabled, ask your host to enable the GD library.

Alternatively, if you have access to the cPanel or equivalent, provided by your host, to manage the web server, go to the Software section and look for PHP or 'PHP Selector', the selection of the PHP version. Check the list of all the PHP extensions and make sure that GD is selected.
Toivo Talikka, Global Moderator

jerry258
Joomla! Apprentice
Joomla! Apprentice
Posts: 49
Joined: Wed Jun 01, 2022 9:44 pm

Re: $color is out of range

Post by jerry258 » Mon May 29, 2023 4:43 pm

Thanks for your reply.
Q1: Plugins>filesystem/local; according to MySitesGuru, it is best to have thumbnails on.
Q2: The image files on my system come from a variety of sources, some modified by Photoshop. I don't know where else
Q3: in systeminformation>phpsettings> GD Available yes
Q4: Version of GD Library is: 2.3.3, and everything is enabled

The problem only occurred after setting thumbnails to on (Q1)
One more possible hint. I can only replicate this problem when creating a new article. I have JCE editor installed. If I select the insert image icon in the editor, i can add an image without a problem. If instead I go to the buttons at the bottom of the editor and click the "media" button, I get the ..." color out or range" error before selecting an image.

User avatar
toivo
Joomla! Master
Joomla! Master
Posts: 17439
Joined: Thu Feb 15, 2007 5:48 am
Location: Sydney, Australia

Re: $color is out of range

Post by toivo » Mon May 29, 2023 10:13 pm

jerry258 wrote:
Mon May 29, 2023 4:43 pm
If instead I go to the buttons at the bottom of the editor and click the "media" button, I get the ..." color out or range" error before selecting an image.
Those buttons are part of the JCE editor. Which version of JCE does the website use? Is it the free version or the paid Pro version?

The problem may be caused the way JCE processes the images and the color or transparency properties of one or more images in the images folder. It would be best to create a topic at the JCE support forum to get an expert answer.
Toivo Talikka, Global Moderator

jerry258
Joomla! Apprentice
Joomla! Apprentice
Posts: 49
Joined: Wed Jun 01, 2022 9:44 pm

Re: $color is out of range

Post by jerry258 » Thu Jun 01, 2023 6:10 pm

toivo Thanks for your help. I am using the basic JCE editor. I note that there is a known bug in the Media Manager editor. I took a look at the images I have been provided, and find that a number of them are oversize. Perhaps that with the "thumbnails" trying reduce them down have caused the problem. Until the bug is fixed, I'll just remove the thumbnails. I'll close this out for now. Thanks again

User avatar
toivo
Joomla! Master
Joomla! Master
Posts: 17439
Joined: Thu Feb 15, 2007 5:48 am
Location: Sydney, Australia

Re: $color is out of range

Post by toivo » Thu Jun 01, 2023 10:12 pm

Thank you for the update! Which particular bug in Media Manager do you mean?
Toivo Talikka, Global Moderator


Post Reply

Return to “Administration Joomla! 4.x”