Adding transparent border to png images
Adding transparent border to png images
Noob question. New to magick. I need to batch add transparent padding to thousands of .png images of varying dimensions. I need to increase the size of the canvas so that there is 20px of transparent space added to the height and width of every image, similar to how you would add 20px to the canvas size in photoshop to add extra space around the image. Can anyone help me with this?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Adding transparent border to png images
Please always provide your IM version and platform, since syntax may differ.
In IM 6, you can do that for all images in a given directory using mogrify. Best to create a new directory to hold the output in case of mistakes before using mogrify. It will not create directories.
in IM 7, the syntax is slightly different
For novices, see
viewtopic.php?f=1&t=9620
http://www.imagemagick.org/script/comma ... essing.php
http://www.imagemagick.org/Usage/reference.html
http://www.imagemagick.org/Usage/
In particular, see
https://www.imagemagick.org/Usage/basics/#mogrify
https://www.imagemagick.org/Usage/crop/#border
In IM 6, you can do that for all images in a given directory using mogrify. Best to create a new directory to hold the output in case of mistakes before using mogrify. It will not create directories.
Code: Select all
cd to current_directory
mogrify -path path2/new_directory -bordercolor transparent -border 20 -format png *.png
Code: Select all
cd to current_directory
magick mogrify -path path2/new_directory -bordercolor transparent -border 20 -format png *.png
viewtopic.php?f=1&t=9620
http://www.imagemagick.org/script/comma ... essing.php
http://www.imagemagick.org/Usage/reference.html
http://www.imagemagick.org/Usage/
In particular, see
https://www.imagemagick.org/Usage/basics/#mogrify
https://www.imagemagick.org/Usage/crop/#border
Re: Adding transparent border to png images
Thank you. This helped me a lot.