What is the best way to add whitespace?
I have an image of 200x150 and it needs to be displayed in a square format (200x200) with 25 pixels whitespace above and below the image to fill out.
The only example I could find first stretches the image to fill the square and then uses the borderimage command to put borders above and below the image. But it seems to me that will both waste a lot of time and deteriorate the quality of the image.
Can some Imagick guru enlighten me on this subject?
Adding whitespace
-
- Posts: 7
- Joined: 2016-02-14T07:50:18-07:00
- Authentication code: 1151
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Adding whitespace
Code: Select all
convert in.png -gravity center -extent 200x200 out.png
snibgo's IM pages: im.snibgo.com
-
- Posts: 7
- Joined: 2016-02-14T07:50:18-07:00
- Authentication code: 1151
Re: Adding whitespace
Hi Snibgo, Thanks.
Is it also possible to do this with the PHP object? There is an setImageGravity method but it takes only one argument and offers not the possibility to define a second image.
Is it also possible to do this with the PHP object? There is an setImageGravity method but it takes only one argument and offers not the possibility to define a second image.
Re: Adding whitespace
You are looking for the following method: http://php.net/manual/en/imagick.extentimage.php (-extent)
-
- Posts: 7
- Joined: 2016-02-14T07:50:18-07:00
- Authentication code: 1151
Re: Adding whitespace
Hi dlemstra,
That solves my problem. Thanks.
That solves my problem. Thanks.