ImageMagick extend canvas with transparent background

Use this instead:

convert               \
      input.png       \
     -background none \
     -gravity center  \
     -extent 100x100  \
      output.png

Note well: The order of the parameters is significant! (To convince yourself, just put -background none at the end of the parameters instead of the start…)


Updated: Thanks to @jesmith who noticed that the commandline I originally provided does no longer work as intended. More recent versions of convert additionally require that the -gravity center is called before -extent 100x100. (This was one of the changes introduced to one ImageMagick’s most recent versions [at the time of originally writing this answer]).

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)