Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to superimpose one image over another using PHP

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 2.71k
    Comment on it

    Hello Readers if you have two images i.e. one png and one jpg, Then by using PHP you can merge both on a single one.

    Lets see the example as given below:-

    <?php
     # If you don't know the type of image you are using as your originals.
     $image = imagecreatefromstring(file_get_contents($your_original_image));
     $frame = imagecreatefromstring(file_get_contents($your_frame_image));
     # If you know your originals are of type PNG.
     $image = imagecreatefrompng($your_original_image);
     $frame = imagecreatefrompng($your_frame_image);
     imagecopymerge($image, $frame, 0, 0, 0, 0, 50, 50, 100);
     # Save the image to a file
     imagepng($image, '/path/to/save/image.png');
     # Output straight to the browser.
     imagepng($image);
    ?>
    

    In the abouve code one image is $image and another is the $frame. The output of the image will be the single image with image over the frame.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: