ImageMagick is a powerful framework for doing all kinds of image editing from the command line. Cropping is a part of it.
See the documentation here: http://www.imagemagick.org/Usage/crop/
Of special interest for you might be the trim
command: http://www.imagemagick.org/Usage/crop/#trim
However, it might very well be, that a simple repage
does the job. This depends on how your PNG image is built: PNGs can contain layer boundary information. trim
will be perfectly fine for you, but repage
might be faster when dealing with a huge amount of images.
When ImageMagick is installed, try these commands: identify
, display
, convert
, mogrify
on your images.