Portal Home > Knowledgebase > Articles Database > PHP error


PHP error




Posted by xeno007, 12-23-2008, 12:28 PM
Hello. Time after time (without rule) I get this error A PHP Error was encountered Severity: Warning Message: imagecolorsforindex() [function.imagecolorsforindex]: Color index -2147483648 out of range Filename: scripts/class.upload.php Line Number: 3374 The content of scripts/class.upload.php from line 3366 to 3386 is this // if the image doesn't support any transparency, then we merge it with the default color $this->log .= '    fills in transparency with default color
'; sscanf($this->image_default_color, "#%2x%2x%2x", $red, $green, $blue); $transparency = imagecolorallocate($image_dst, $red, $green, $blue); // make the transaparent areas transparent for ($x = 0; $x < $this->image_dst_x; $x++) { for ($y = 0; $y < $this->image_dst_y; $y++) { // we test wether we have some transparency, in which case we will merge the colors $pixel = imagecolorsforindex($image_dst, imagecolorat($image_dst, $x, $y)); if ($pixel['alpha'] == 127) { // we have full transparency. we make the pixel transparent imagesetpixel($image_dst, $x, $y, $transparency); } else if ($pixel['alpha'] > 0) { // we have some transparency. we combine the color with the default color $alpha = ($pixel['alpha'] / 127); $pixel['red'] = round(($pixel['red'] * (1 -$alpha) + $red * ($alpha))); $pixel['green'] = round(($pixel['green'] * (1 -$alpha) + $green * ($alpha))); $pixel['blue'] = round(($pixel['blue'] * (1 -$alpha) + $blue * ($alpha))); $color = imagecolorclosest($image_dst, $pixel['red'], $pixel['green'], $pixel['blue']); imagesetpixel($image_dst, $x, $y, $color); } If it helps, that happens when you see a picture on the website for the first time. After you refresh the page you wont see that error (unless you go to another picture that you see for the first time). Thanks for your help.

Posted by Ogg, 12-23-2008, 01:51 PM
Are you sure that $this->image_dst_x and $this->image_dst_y are within the actual range of the image?



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read
FFLVtool2 error (Views: 521)