Help with my Image Merging script

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Help with my Image Merging script

    help!,i wanted to add a photo on another photo but it keeps returning the original photo after uploading
    PHP Code:
    $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); 
    Last edited by Busary; 18.07.13, 19:42.

    #2
    ok, thanks to php.net...


    PHP Code:
    <?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
    Last edited by pmbguy; 08.08.13, 19:49. Reason: adding demo
    C3 Themes: http://c3themes.wen.ru/index.html
    Find Files: http://mystarter.tk/?goto=X-search

    Comment

    Working...
    X