开发者

Merge Two images together on Server, then save

I'm new to php, but i'm fairly certain this is possible to do. I have a bunch of images on my server, and i'd like to give them all a thick black border. I know i could use CSS, but i'd rather the border was real. My images are all the same size, so it's nothing more than centering the server image onto this black box image, then merging them together and re-saving the server image.

I could technically do this in photoshop too, but there's a ton of images...

Bonus

If i could shrink t开发者_开发知识库he image after i'm done, that'd be nice too. They are a bit larger than i need.


Take a look at imagemagicks, see some examples here http://www.imagemagick.org/script/examples.php

You can call it via exec() from PHP

e.g. aligning two images next to each other, adding a border around each of them:

$cmd = 'montage image1.jpg image2.jpg -tile x1  -border 5 -geometry +5+5   result.jpg';
exec($cmd);


The GD2 library also gives generally good results if ImageMagick isn't installed on your server.

See some tutorials here: http://www.roseindia.net/tutorial/php/phpgd/

Some say that ImageMagick gives better results in many cases, but GD2 may suit what you need just fine and is fairly easy to use. Hopefully, it matches the use case you're describing.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜