Remove alpha channel in an image
The accepted answer to export to JPG, then back to PNG is not recommended.
- It's an extra step in the process (2 exports)
- JPG is lossy, so you will lose some image data
Here's a super fast and easy way to do this without the extra export or saving to (lossy) JPG:
Using Preview app (Mac):
- Open the image
- Command-Shift-S to Duplicate (creates a copy)
- Command-S to Save
- Deselect the "Alpha" checkbox
- Delete " copy" from filename (including the space)
- This will overwrite your original, if you want to keep the original, just leave "copy" in the name
- Save
- Click 'Replace' to confirm you want to overwrite the original
- Only necessary if you are overwriting your original
if you need remove all alpha channel from directory with icons use this command:
for i in `ls *.png`; do convert $i -background black -alpha remove -alpha off $i; done
if you have Mac OS Mojave and had "convert command not found"
brew install imagemagick
To install Homebrew
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null