开发者

Merging (watermark) a jpg with png while resizing the png in PHP GD

开发者 https://www.devze.com 2023-01-07 00:44 出处:网络
I am sure I could somehow figure this out but it\'s just taking me way too long since I am not a PHP guy. Hopefully someone can set up the script for me in minutes...

I am sure I could somehow figure this out but it's just taking me way too long since I am not a PHP guy. Hopefully someone can set up the script for me in minutes...

So here's what I need to do:

I transmit 2 pictures from a smartphone to a webserver. These 2 images need to be merged (watermarked). They differ a little:

  1. picture is a 2 megapixel jpg (holding a photo)
  2. picture will be a png of 480x800 pixels with a transparent background (holding a simple finger painting)

Now I need to merge these images. The 2nd one (png) needs to be scaled to the 1st one's (jpeg) resolution.

Please note 2 things:

  1. I can only use the GD library that is installed on the server. Imagick or alike is not available
  2. I am well aware of the fact that the 2nd image's quality won't be brilliant. That's okay.

So could anyone help me out on this? Like I said, I've been messing around with a 开发者_如何学Pythoncouple of GD functions but progress is far too slow. I guess I found the required functions with imagecopy and watermark. But I don't find the right way to put 'em together.

Thanks in advance,

steff

Thanks a million


A few months ago i posted a function that does that, since the code is quite big i will just link my post, check it out here. Make sure you don't do this onfly, it will overload your server, save the watermarked images or at least cache them.

If you also need to resize the original or watermark, i also posted a function to do this here.

0

精彩评论

暂无评论...
验证码 换一张
取 消