gausie Posted July 6, 2007 Share Posted July 6, 2007 Hi there! I've got a couple of gifs that I'd like to randomly pick. I got that sorted with this: <?php $classes = array ("AT", "DB", "PM", "SC", "SR", "TT"); header("Content-Type: image/gif"); @readfile("./" . $classes[rand(0,5)] . ".gif") or die("File not found."); ?> However, it is now appropriate to overlay some text on each gif. So I tried this: <?php $classes = array ("AT", "DB", "PM", "SC", "SR", "TT"); $string = "Random Picture"; $chosen = "./" . $classes[rand(0,5)] . ".gif"; $im = imagecreatefromgif($chosen); $black = imagecolorallocate($im, 0, 0, 0); imagestring($im, 1, 0, 0, $string, $black); imagegif($im); imagedestroy($im); ?> But that's just giving me a text version of my GIF: GIF87a<�d����������������������HHH&&&���,,,�..... So my problems here are Problem displaying the image I don't even know if it's working to overlay on every frame of the animation, since it wont display gausie Quote Link to comment Share on other sites More sharing options...
Barand Posted July 6, 2007 Share Posted July 6, 2007 As far as I know, animated gifs aren't supported. You could use css to overlay text over the image. Quote Link to comment Share on other sites More sharing options...
gausie Posted July 6, 2007 Author Share Posted July 6, 2007 No, I'm making something that will be used on other people's websites :-( Quote Link to comment Share on other sites More sharing options...
Barand Posted July 6, 2007 Share Posted July 6, 2007 I just tried with one of my animated gifs It overlays the text but loses the animation (you forgot the content-type header, btw) <?php $string = 'ABC'; $chosen = "connection.gif"; $im = imagecreatefromgif($chosen); $black = imagecolorallocate($im, 0, 0, 0); imagestring($im, 1, 0, 0, $string, $black); header("content-type: image/gif"); imagegif($im); imagedestroy($im); ?> Quote Link to comment Share on other sites More sharing options...
gausie Posted July 6, 2007 Author Share Posted July 6, 2007 Hmm would there be a way to dissect the gif, apply the change to each frame, and then output it with all these frames together? This, on the fly? gausie Quote Link to comment Share on other sites More sharing options...
Barand Posted July 6, 2007 Share Posted July 6, 2007 ImageMagick supports gif animation. Might be worth a look Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.