Help with my Image Merging script

Started on the old forum in July 2013 · view the original in the archive · old links redirect here

1 reply · 562 views · started 13 years ago · 1 min read

2 participants
Busary Junior · 14 posts #1

help!,i wanted to add a photo on another photo but it keeps returning the original photo after uploading

$filepath=$folder.$filename;

$logo_file = "pics/add.png";
$photo = imagecreatefromjpeg($filepath);
$fotoW = imagesx($photo);
$fotoH = imagesy($photo);
$logoImage = imagecreatefrompng($logo_file );
$logoW = imagesx($logoImage);
$logoH = imagesy($logoImage);
$photoFrame = imagecreatetruecolor ($fotoW,$fotoH);
$dest_x = $fotoW - $logoW;
$dest_y = $fotoH - $logoH;
imagecopyresampled($photoFrame, $photo, 0, 0, 0, 0, $fotoW, $fotoH, $fotoW, $fotoH);
imagecopy($photoFrame, $logoImage, $dest_x, $dest_y, 0, 0, $logoW, $logoH);
imagejpeg($photoFrame, $filepath );

imagedestroy($photo);
pmbguy Senior · 344 posts #2

ok, thanks to php.net...

<?php
// Load the stamp and the photo to apply the watermark to
$stamp = imagecreatefromjpeg('pics/bbc.jpg');
$im = imagecreatefromjpeg('images/Cars.jpg');

// Set the margins for the stamp and get the height/width of the stamp image
$marge_right = 2;
$marge_bottom = 2;
$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);
?>

Demo: http://mystarter.tk/imagemerge

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close