Remove alpha channel from png images

Every time you upload a screenshot on the App Store for a new app submission, you receive from Apple this error message:

“Images can’t contain alpha channels or transparencies.”

This is tedious if you don’t have Photoshop installed or you don’t have idea how to remove the alpha channel on the generated images.

Today I propose two simple methods, the first one is very simple and can be done without installing anything, the second one can be scripted (that I prefer).


Use macOS Preview

Open your image with system Preview.app, open menu File and select “Duplicate”, or better use CMD + SHIFT + S.

Than save (CMD + S) the duplicated image and pay attention to remove the flag “Alpha channel” before saving.

Done √


Use ImageMagick from shell

A little bit “complicated”, first of all, you need to install ImageMagick (via Brew), my favorite image editing tool from the command line.

Use ImageMagick® to create, edit, compose, or convert bitmap images. It can read and write images in a variety of formats (over 200) including PNG, JPEG, GIF, HEIC, TIFF, DPXEXR, WebP, Postscript, PDF, and SVG. Use ImageMagick to resize, flip, mirror, rotate, distort, shear and transform images, adjust image colors, apply various special effects, or draw text, lines, polygons, ellipses and Bézier curves.

imagemagick.org

$ brew install imagemagick

The advantage of using ImageMagick is that can be scriptable, you can create your own script that edit, convert, modify a batch of images.

To remove the alpha channel the options are:

$ convert IMAGE_TO_CONVERT.PNG -background white -flatten IMAGE_CONVERTED.PNG

That’s all, your image is now without alpha channel.

Enjoy magick!

 

Alberto Pasca

Software engineer @ Pirelli & C. S.p.A. with a strong passion for mobile  development, security, and connected things.