03-15-2009, 01:32 AM
|
#3 (permalink)
|
|
The Contributor
Join Date: Mar 2009
Location: US
Posts: 76
Thanks: 0
|
This will not work as the GD library does not run the PHP script and only tries to load the JPEG image.
An alternative to this could be the following
PHP Code:
// image.php $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));
// Save image imagejpeg($img, 'testimage.jpeg'); imagedestroy($img);
// redirect to view header('location: view.php');
PHP Code:
// view.php // Redirect if there is no image if (!file_exists('testimage.jpeg')) { require('image.php'); }
// Load Image $im = imagecreatefromjpeg('testimage.jpeg');
// Delete image @unlink('testimage.jpeg'); // 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);
Tested and works
|
|
|
|