Thread: PHP GD query
View Single Post
Old 03-13-2009, 04:04 AM   #1 (permalink)
Farmer
The Visitor
 
Farmer's Avatar
 
Join Date: Dec 2008
Posts: 4
Thanks: 0
Farmer is on a distinguished road
Red face PHP GD query

I am trying to get the index color of a image but still no luck. I have 2 files.

-- image.php [GD generated image]
-- view.php [File to view the index color of image.php]

image.php

Code:
header("Content-Type: image/jpeg");

$img = imagecreate("200", "150");
$bgcolor = imagecolorallocate($img, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
$text = imagecolorallocate($img, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));

imagejpeg($img);
imagedestroy($img)
view.php
Code:
$im = imagecreatefromjpeg('image.php');

// get a color
$start_x = 20;
$start_y = 20;
$color_index = imagecolorat($im, $start_x, $start_y);

// make it human readable
$color_tran = imagecolorsforindex($im, $color_index);

print_r($color_tran);
when i try other normal jpeg file it return values but when i try image.php file it'll not to return the value. Can you help me here.
Farmer is offline  
Reply With Quote