2

I'm trying to add padding to the top of an image using the command line.

I've found the sips command and I've tried

sips --padToHeightWidth 1300 1920 image.png

on an image which is 1920 x 1080.

However this adds 50px of padding to the top and bottom.

Is it possible to just add 100px of padding to the top?

Is there another tool I should/could be using to do this?

1

I do not believe you can do that with sips. I would recommend ImageMagick which you can easily install using Homebrew. Then the command is:

convert  InputImage.jpg -background blue -splice 0x100 PaddedResult.jpg

enter image description here enter image description here

If you want to add transparent padding, use:

convert  InputImage.jpg -background transparent -splice 0x100 out.png

If you want to composite two images together, you can do this:

convert -size 1024x768 xc:blue 1024x768.jpg                    # create big blue image
convert -size 100x100 xc:red 100x100.jpg                       # create little red image
composite -gravity northeast 100x100.jpg 1024x768.jpg out.jpg  # superimpose top right

Note that I am creating my images first, you can obviously just use your own.

enter image description here

3
  • Did this work for you? If so, please consider accepting it as the answer. If not, please say what went wrong so that I, or others, can assist you further. – Mark Setchell Jul 10 '14 at 8:18
  • Thanks for your answer. Would I be able to add transparent padding to a png using this method. And also would I be able to overlay other images and combine them into a single image? e.g I have a 1024x768 image and a 100x100 image and I want to put the 100x100 image in the top right corner of the 1024x768 image – Jacob Tomlinson Jul 11 '14 at 10:05
  • Please have another look, I have updated my answer. – Mark Setchell Jul 11 '14 at 10:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .