Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Combine two images (.JPG) using PHP GD

I can't find a solution to this. I want to add 20px empty space to this image: http://img233.imageshack.us/img233/419/78317401.jpg

and then paste this watermark at the bottom (on the blank space)

So the output would be:

http://img252.imageshack.us/img252/4554/wynik.jpg

I don't want to stretch it.

EDIT

Did it with WIdeImage. Rly simple.

like image 762
Dreszczyk Avatar asked Nov 29 '22 10:11

Dreszczyk


2 Answers

Try wide image api http://wideimage.sourceforge.net/
Check out one of their this demo may be that help you
Merge and Resize

like image 20
Ali Nouman Avatar answered Dec 09 '22 17:12

Ali Nouman


1) Load both images with

http://www.php.net/manual/en/function.imagecreatefromjpeg.php

2) Get 1st image height and width with

http://www.php.net/manual/en/function.imagesy.php

http://www.php.net/manual/en/function.imagesx.php

3) Create larger image with height+20

http://www.php.net/manual/en/function.imagecreatetruecolor.php

4) Copy the first image and the second image to the larger image

http://www.php.net/manual/en/function.imagecopy.php

5) Save it

http://www.php.net/manual/en/function.imagejpeg.php

6) Done

like image 162
Leonid Shevtsov Avatar answered Dec 09 '22 18:12

Leonid Shevtsov