StoryTeller
StoryTeller

Reputation: 1748

How do I save an image with a border (not adding it with CSS)?

An Image should be stored in a specific format and the remaining space should be filled black. My problem is, that the picture is'nt shown in an html page, it should just be converted and stored in the described way. Is there any simple sollution with PHP?

Upvotes: 1

Views: 278

Answers (1)

Bjoern
Bjoern

Reputation: 16304

You could use Imagick. Imagick is a native php extension to create and modify images. It has a specific function for that called Imagick::borderImage.

Something like this could do the job:

$image = new Imagick('your_image.jpg');
$color=new ImagickPixel();
$color->setColor("rgb(100,200,50)");
$image->borderImage($color,1,1);
$image->writeImage('your_bordered_image.jpg');

You might have to adjust those code lines slightly, I just have thrown them together.

Upvotes: 4

Related Questions