How can I use ImageMagick to batch resize and use -extent with transparency?

2

  • Version: ImageMagick 7.0.8-68 Q16 x64 2019-10-05
  • Windows 10: 1903

I have hundreds of logos that I need to resize to a standard and then use -extent to pad back out.

magick 608000000000051.png -resize 500x325^> -gravity center -extent 500x325 done.png

original (green added to show transparency) enter image description here but it adds a white background and I want to retain the transparency. After hours of reading docs I can't find a solution, can this be done with Imagemagick? enter image description here

chris loughnane

Posted 2019-10-12T02:15:02.370

Reputation: 153

Try using the -alpha command line option; transparency equates too the alpha channel in ImageMagick and other image — and even video — processing tools.

– JakeGould – 2019-10-12T02:41:41.533

I just spend 90 minutes with that command and I cannot to save my live get anything other than a white background. TBH I'm getting quite frustrated with this – chris loughnane – 2019-10-12T15:43:57.460

Answers

2

Got it! :)

This resizes your image, centers it, sets the canvas to a standard size and maintains transparency.

magick 608000000000051.png -background none -resize 500x325^> -gravity center -extent 500x325 done.png

chris loughnane

Posted 2019-10-12T02:15:02.370

Reputation: 153