What should I do about this warning? Is it a php, image module, or picture problem?
warning: imagecolorsforindex(): Color index 49 out of range in /var/www/html/includes/image.inc on line 251.

Comments

drewish’s picture

what are you doing when you see it? using the color module?

Eudaimonius’s picture

I changed the thumbnail size (?q=admin/settings/image).
"* Changes to the images sizes mean that the derivative images will need to be regenerated."
"* The configuration options have been saved."

Upon viewing a page containing thumbnails:
"The derivative images for picture_xyz have been regenerated."
"warning: imagecolorsforindex(): Color index 49 out of range in /var/www/html/includes/image.inc on line 251."

batigolix’s picture

maybe because of (animated) gifs: http://drupal.org/node/218045#comment-862584

jfall’s picture

Project: Image » Drupal core
Version: 5.x-1.7 » 5.7
Component: image.module » other

No, I don't think so.

I'm getting exactly this error - but I don't use image.module - the error occurs in image.inc in core (so I moved this issue)

I'm getting the following error (in log):
function.imagecolorsforindex: Color index 255 out of range in /home2/lasqica/public_html/includes/image.inc on line 251.

Here's the relevant code:

$transparency_index = imagecolortransparent($im);
if ($transparency_index >= 0) {
    // Get the original image's transparent color's RGB values.
    $transparent_color = imagecolorsforindex($im, $transparency_index);
    //  -->  $transparency_index == 255 -> out of range error.   <--

I checked my image - it DOES use color 255 for transparency (this is the highest index in image), which is correctly returned from imagecolortranparent().

I'm guessing this is a PHP issue? I'm running PHP 5.2.5 Anyone heard of it before? Is there a workaround / patch?

Any ideas? Thanks.

ali27’s picture

Assigned: Unassigned » ali27

int $index=imagecolortransparent ( resource $image [, int $color ] )
Sets the transparent color in the given image .

image
An image resource, returned by one of the image creation functions, such as imagecreatetruecolor().

array imagecolorsforindex ( resource $image , int $index )
Gets the color for a specified index

try to put a $index less than 255

for more information about php functions go to php.net there you can found all you want

http://www.php.net/manual/en/function.imagecolorsforindex.php

ainigma32’s picture

Status: Active » Fixed

Solution provided. Setting to fixed.

Feel free to reopen if you think that is wrong.

- Arie

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

AppleBag’s picture

I'm not quite clear on the solution, can someone explain it a bit more? thanks

AppleBag’s picture

Anyone? Getting a ton of these in watchdog.

AppleBag’s picture

Status: Closed (fixed) » Active

Bueller ..?

Buelllller ... ?

j0rd’s picture

Same issue here. Unsure of fix.

 Color index 255 out of range in /home/.zulu/user/site.com/htdocs/includes/image.gd.inc on line 108.
drewish’s picture

Status: Active » Postponed (maintainer needs more info)

i need to see one of these images.

AppleBag’s picture

drewish’s picture

Status: Postponed (maintainer needs more info) » Closed (won't fix)

the problem is that gd can't resize animated gifs so there's not much that can be done here.

AppleBag’s picture

Is there any way to suppress the error in that case, so it doesn't fill the watchdog with tons of the error messages? As far as I can tell, other than that error message, nothing else is affected.

j0rd’s picture

Here's the one it happens for me on: http://www.newswire.ca/images/companies/logo_6828.gif

@AppleBag. You could append @ in front of the function I believe. I think that's PHP's lame/awesome way of suppressing errors.

http://us.php.net/operators.errorcontrol

Dr Trichome’s picture

Hi,

I had a similar error using Drupal 6, using imagepicker module. If I uploaded a gif, I would get that error (it was not an animated gif). I solved the problem by removing the alpha from my gif. Note: I use a mac. I opened the image file in Preview, went to file->save as..., and in the dialog box that comes up, I unchecked the box for alpha. Then saved the gif and it uploaded just fine--no more errors. Alternatively, I guess you could save the file as a jpg. I hope this helps.

ricky1006’s picture

I have the same problem. I solved by removing the transparency of the image and the error disappears.