Jump to content

[SOLVED] PHP put an image into another


golles

Recommended Posts

First of all, I don't know if this is possible, hope so.

 

I have edited an image with PHP, put some text on multiple places with the following code

 

<?php
$imgtext = "TEST";

$im = imagecreatefromjpeg("myimg.jpg");
$textcolor = imagecolorallocate($im, 0, 0, 0);
$font = 4;

imagestring($im, $font, 180, 270, "$imgtext", $textcolor);

header("Content-type: image/jpg");
imagepng($im);
imagedestroy($im)
?>

 

what I want next is to put some other images (multiple) into this one (myimg.jpg).

 

hope you do understand what I want :P

and hope you can tell me that it is posible and how I can do it.

 

many many thank

 

 

//golles

 

PS. it is just for a fun project from me and a mate

 

Link to comment
https://forums.phpfreaks.com/topic/68051-solved-php-put-an-image-into-another/
Share on other sites

use imagecopy(), or imagecopymerge() if you want to vary the transparency

I have tried imagecopy() but it aint working probably I'm doing something wrong, but I can't see what I'm doing wrong

 

Warning: imagecopy(): supplied argument is not a valid Image resource in C:\...\test.php on line 11

 

Warning: Cannot modify header information - headers already sent by (output started at C:\...\test.php:11) in C:\...\test.php on line 13

 

this is the code I'm using:

<?php
$imgtext = "TEST";
$groen = "groen.jpg";

$im = imagecreatefromjpeg("myimg.jpg");
$textcolor = imagecolorallocate($im, 0, 0, 0);
$font = 4;

imagestring($im, $font, 180, 270, "$imgtext", $textcolor);

imagecopy($im, $groen, 50, 400, 0, 0, 51, 57);

header("Content-type: image/jpg");
imagepng($im);
imagedestroy($im)
?>

 

hope you can help me with this.

thanks in advance

 

 

//golles

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.