2009-04-03 10 views
2

Existe-t-il un moyen de mettre du texte sur un png et de le fusionner avec une image jpg/gif?fusionner des images avec du texte

+0

Pouvez-vous élaborer votre question un peu plus? Que voulez-vous dire par fusionner png avec image jpg/gif? – Alekc

Répondre

1

Voici comment je le fais.

/* load the image */ 
$im = imagecreatefrompng("image.png"); 

/* black for the text */ 
$black = imagecolorallocate($im, 0, 0, 0); 

/* put the text on the image */ 
imagettftext($im, 12, 0, 0, 0, $black, "arial.ttf", "Hello World"); 

/* load the jpg */ 
$jpeg = imagecreatefromjpeg("image.jpeg"); 

/* put the png onto the jpeg */ 
/* you can get the height and width with getimagesize() */ 
imagecopyresampled($jpeg,$im, 0, 0, 0, 0, $jpeg_width, $jpeg_height, $im_width, $im_height); 

/* save the image */ 
imagejpeg($jpeg, "result.jpeg", 100); 

Ceci est un exemple plutôt simple.