Page 1 of 1

Adding whitespace around an image to make it the right size

Posted: 2008-06-21T00:45:58-07:00
by roger_pearse
I hardly ever use ImageMagick, excellent tho it is, so I hope that people will bear with me if I'm asking a silly question.

I want to reprint an old book on lulu.com. I've scanned the pages as images (jpgs). But each image is smaller than the page size that lulu want.

What this means is that lulu resize the image to fill the space, which distorts it.

What I want to do is to put whitespace all the way around the image, to fill it out to the size (in inches or cms) that I need. In this way the image of the page text will remain the same size, but the actual file will be larger.

Can anyone tell me how best to do this? I saw the -border, but this seemed to involve me specifying the width of the border, rather than the end-size of the image.

Suggestions very welcome.

All the best,

Roger Pearse

Re: Adding whitespace around an image to make it the right size

Posted: 2008-06-21T08:15:01-07:00
by fmw42
use -extent with -gravity

see http://www.imagemagick.org/Usage/crop/#extent

Re: Adding whitespace around an image to make it the right size

Posted: 2008-06-21T14:22:17-07:00
by Bonzo
Why don't you just create a blank white image the correct size and put your other image onto it?

Code: Select all

convert -size 400x600 xc:white page.jpgs -gravity center -composite output.jpgs
You will need to work out the size but when you have it correct it will work for all the pages.

Re: Adding whitespace around an image to make it the right size

Posted: 2008-06-23T00:01:07-07:00
by roger_pearse
Ah! Yes, of course that would work, wouldn't it?! Thank you for the syntax -- I'll try that.

Re: Adding whitespace around an image to make it the right size

Posted: 2008-06-23T17:25:18-07:00
by anthony
There are about a dozen methods you can use for 'padding' an image. The above are the two best methods... See
http://imagemagick.org/Usage/thumbnails/#pad

Re: Adding whitespace around an image to make it the right size

Posted: 2008-06-24T00:21:50-07:00
by roger_pearse
Thank you also -- ah, I knew it had to be an FAQ!

Roger