2016-01-28 4 views
1

J'ajoute une ligne de texte sur une image. Est-il possible de superposer plusieurs lignes (line2.png & line3.png) sur la même image?ajouter plusieurs pngs à l'image php

$stamp = imagecreatefrompng('img/line1.png'); 
$im = imagecreatefromjpeg('tom.jpg'); 

// Set the margins for the stamp and get the height/width of the stamp image 
$marge_right = 10; 
$marge_bottom = 40; 
$sx = imagesx($stamp); 
$sy = imagesy($stamp); 

// Copy the stamp image onto our photo using the margin offsets and the photo 
// width to calculate positioning of the stamp. 
imagecopy($im, $stamp, imagesx($im) - $sx - $marge_right, imagesy($im) - $sy - $marge_bottom, 0, 0, imagesx($stamp), imagesy($stamp)); 

// Output and free memory 
header('Content-type: image/png'); 
imagepng($im); 
imagedestroy($im); 

Répondre

0

Oui, vous pouvez utiliser imagecopy.

Utilisation typique:

$copyimage = imagecreatefromjpeg("path/to/image/you/want/to/put/into/an/image.jpg"); 
//$copyimage just needs to be a GD object, so you can also use imagecreatefrompng etc. 
imagecopy($image, $copyimage, $position_x, 
      $position_y, 0, 0, $image_width, $image_height); 

http://php.net/imagecopy