I need to process a set of identically formatted images to get them to conform with my client's website format. I wanted to use ImageMagick's convert or mogrify instead of ffmpeg but I just cant make it work in a clean way. I tried the -border and -extent options but they behaved sort of inconsistently, so I'm thinking about falling back to the pad filter in ffmpeg:

ffmpeg -i input.jpg -vf "pad=1500:1500:(ow-iw)/2:(oh-ih)/2:color=white" output.jpg

This is just so much more straightforward - you set the canvas size, the location, and the color, and that's it. Is there a similar solution using the ImageMagick tools?

  • 4
    What have you tried with IM and how did it not work? – slhck Jun 16 '19 at 13:26

I found something that works for me:

convert input.jpg -extenet WIDTHxHEIGHT+X+Y -background COLOR output.jpg

this allows offsetting much like with the pad filter in ffmpeg. I think what confused me is that the -bordercolor option doesn't seem to work on my setup with the convert command, while it works fine with mogrify. I don't know whether I'm missing something or this is a bug.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.