简体   繁体   中英

Adding text to image (animated gif) with PHP

I want to allow my website visitors to personalize their banners with their names.

1) The banners are animated GIFs, but the script only seems to output the first frame of the GIF image

2) I need to add a text field to allow users to enter their desired text. After submitting the form, the image will be generated with their text

Thank you!

index.php (below)

<img src="image.php?text=MyNameHere" alt="" />

image.php (below)

<?php

//Image
$rImg = ImageCreateFromGIF("image.gif");

//Definir cor
$cor = imagecolorallocate($rImg, 0, 0, 0);

//Text
imagestring($rImg,5,126,22,urldecode($_GET['nome']),$cor);

//Header output
header('Content-type: image/gif');
imagegif($rImg,NULL,100);

?>

Here's a class file with tons of options for text overlay and/or image overlay. class.upload.php

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM