[ALUG] ImageMagick convert
Bill Hill
mail at wbh.org
Wed Mar 18 14:32:40 GMT 2009
Mark Rogers wrote:
> Any experts in using ImageMagick lurking?
>
> I need to resize an image to fit into a 350x350 box. Which means I need
> to (a) scale the image so no dimension exceeds 350, then (b) centre the
> image in a 350x350 canvas.
>
> Eg for a 700x600 image, (a) creates a 350x300 image which (b) then
> converts to 350x350 without distorting it (by adding "whitespace".
>
> Ideally I want some control over what the canvas colour ("whitespace")
> will be, in particular transparent would be a good option, but white
> will do for now.
>
> The first bit is easy:
> convert -resize 350x350 old.png new.png
> I've tried various ways to do step (b) without success. (A single
> command which does both would be best, but two separate commands would
> be a start!)
>
convert -border 2x0 -bordercolor #0000FF -resize 350x350 input.jpg
-background #FFE000 -gravity center -extent 350x350 output.jpg
You might want to change the colours, though.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 257 bytes
Desc: OpenPGP digital signature
Url : http://lists.alug.org.uk/pipermail/main/attachments/20090318/72fed8c8/attachment.pgp
More information about the main
mailing list