Combining two images using PHP

I am trying to combine two images together with PHP.

For example ... how can I put the placement of one image on top of the image two or combine with basic PHP? I tried something like watermarks, but it doesn't seem to work.

Image 1

alt text

Image two

alt text

... and turn it into this? FINAL RESULT:

alt text

+56
merge php image resize overlay
Oct 06 '10 at 19:48
source share
6 answers

I got it from one of them.

<?php $dest = imagecreatefrompng('vinyl.png'); $src = imagecreatefromjpeg('cover2.jpg'); imagealphablending($dest, false); imagesavealpha($dest, true); imagecopymerge($dest, $src, 10, 9, 0, 0, 181, 180, 100); //have to play with these numbers for it to work for you, etc. header('Content-Type: image/png'); imagepng($dest); imagedestroy($dest); imagedestroy($src); ?> 
+94
Oct 06 2018-10-10
source share
— -

The question is about merging the two images, however in this particular case you should not do this. You have to put the Content Image (i.e. Cover) in the <img /> and the image style in CSS, why?

  • As I said, the cover refers to the content of the document, and the vinyl record and shadow are only part of the page styles.
  • This separation is much more convenient to use. User can easily copy this image. It is easier to index by web spiders.
  • Finally, it is much easier to maintain.

So use a very simple code:

 <div class="cover"> <img src="/content/images/covers/movin-mountains.png" alt="Moving mountains by Pneuma" width="100" height="100" /> </div> .cover { padding: 10px; padding-right: 100px; background: url(/style/images/cover-background.png) no-repeat; } 
+20
Oct 06 '10 at 23:29
source share

Use the GD library or ImageMagick. I googled 'PHP GD Image Merging' and got some articles about this. In the past, what I did was create a large blank image, and then use imagecopymerge () to paste these images into my original blank. Browse through articles on Google, you will find the source code that you can immediately start using.

+2
Oct 06 2018-10-10
source share

The GD Image Manipulation Library in PHP is probably best suited for working with images in PHP. Try one of the imagecopy functions (imagecopy, imagecopymerge, ...). Each of them combines 2 images in different ways. For more information see php documentation on imagecopy .

+1
Oct 06 2018-10-10
source share

ImageArtist is a pure gd-shell created by me, it allows you to do complex image manipulations insanely easily, it can be done using a very small number of steps to solve the problem using this powerful library.

here is a sample code.

 $img1 = new Image("./cover.jpg"); $img2 = new Image("./box.png"); $img2->merge($img1,9,9); $img2->save("./merged.png",IMAGETYPE_PNG); 

This is what my result looks like.

enter image description here

+1
Sep 14 '17 at 19:05
source share

You can do this with the ImageMagick extension. I assume that the combImages () method will do what you want.

0
Oct 06 2018-10-10
source share



All Articles