How to remove transparency from image(s)?

If you have set of images with transparency, and want to remove transparency from all the images?

You can achieve that by simply using imagemagick, by using following command:

$ mogrify -alpha off image-name.png

First of all make sure you have install the imagemagick. If not then install it using following command:

  • Using apt repositories:
    $ apt-get install imagemagick
  • Using brew:
    $ brew install imagemagick --disable-openmp --build-from-source

If you want to remove alpha channel (transparency) from multiple images then, move all images into one folder and navigate to that folder and use the following command:

$ mogrify -alpha off *.png

It's done! Using single command from ImageMagick we removed alpha channel from all PNG images.

You can also check whether Image contain alpha channel or not by running following command:

$ sips -g all image-name.png

Where -g stands for, --getProperty key

I'm sure you will fall in love with ImageMagic as you explore its usage.

To add border to the image or set of images:

$ mogrify -mattecolor black -frame 10x10 image-name.jpg

You can use the same command to apply multiple border to the image(s)

To convert image into gray scale image(s):

$ mogrify -type grayscale image-name.jpg

To resize the image(s):

$ mogrify -resize 50% image-name.jpg
$ mogrify -resize 500x500 image-name.jpg #To maintain the aspect ratio
$ mogrify -resize 500x500\! image-name.jpg #To ignore the aspect ratio