Is there any way to convert a hex color (#fffff) into a small .GIF image on the fly with PHP?
Asked
Active
Viewed 625 times
0
-
@Pekka: Sharing is caring there, Pekka.. – StealthRT Sep 19 '11 at 19:28
-
see: http://stackoverflow.com/questions/1838794/php-image-creation-from-hex-values-in-database – Tim Sep 19 '11 at 19:28
-
`#fffff` is a hex color? – salathe Sep 19 '11 at 19:31
-
@salathe: oops... forgot another f... #ffffff – StealthRT Sep 19 '11 at 19:34
1 Answers
6
....
<?php
// create the image
$im = imagecreatetruecolor(100, 100);
// fill the image with the color you want
imagefilledrectangle($im, 0, 0, 99, 99, 0xFFFFFF);
// set the headers and output the image
header('Content-Type: image/gif');
imagegif($im);
imagedestroy($im);
?>

Saad Imran.
- 4,480
- 2
- 23
- 33
-
Why was this downvoted? It's an answer to an incredibly lazy question, but it's still a valid answer – Pekka Sep 19 '11 at 19:33
-
-
-
1upvote for answering the question properly, sorry you are being harassed by haters =/ – Francis Yaconiello Sep 19 '11 at 19:50
-
@Saad: Thanks, that worked out just as i needed it too! :o) Francis: Yeah, but you get them every time. – StealthRT Sep 19 '11 at 19:55