Use sips to pad just the top of an image
-
02-10-2020 - |
Question
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?
Solution
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
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.
Licensed under: CC-BY-SA with attribution
Not affiliated with apple.stackexchange