VladB1989 Posted April 5, 2007 Share Posted April 5, 2007 Hi. I'm working at a photo gallery and i'm using a script by Luciano Ropero to determine the most used color in a picture. In a simple file works, but when i use it in pixelpost and when it gets to >> it considers the first > as an end tag and the script doesn't work anymore. I have changed the extension of image_template.html to php and modified all paths in index.php that went to image_template.html to image_template.php. Can you please tell me what should i do? I know the server has gd installed. This is the script: <?php $image=imageCreateFromJPEG('<IMAGE_NAME>'); function average($img) { $w = imagesx($img); $h = imagesy($img); $r = $g = $b = 0; for($y = 0; $y < $h; $y++) { for($x = 0; $x < $w; $x++) { $rgb = imagecolorat($img, $x, $y); $r += $rgb >> 16; $g += $rgb >> 8 & 255; $b += $rgb & 255; } } $pxls = $w * $h; $r = dechex(round($r / $pxls)); $g = dechex(round($g / $pxls)); $b = dechex(round($b / $pxls)); if(strlen($r) < 2) { $r = 0 . $r; } if(strlen($g) < 2) { $g = 0 . $g; } if(strlen($b) < 2) { $b = 0 . $b; }; echo "<body bgcolor=#$r$g$b>"; }; average($image); ?> Please excuse my English if the post has mistakes. Link to comment https://forums.phpfreaks.com/topic/45647-imagecolorat-trouble/ Share on other sites More sharing options...
VladB1989 Posted April 5, 2007 Author Share Posted April 5, 2007 Still no one? Link to comment https://forums.phpfreaks.com/topic/45647-imagecolorat-trouble/#findComment-222076 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.