I have an app icon for iOS but Apple doesn't allow alpha to be in the image. How to remove this alpha channel? I only have the png image with me I don't have the source file as my friend did the image for me.
10 Answers
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
-
2^ this is a better answer, IMHO. JPG doesn't support alpha channels and this will allow you to use a LOSSLESS format and deal with the alpha channel (instead of avoiding it). Jul 18, 2016 at 16:28
-
4I do not understand why iTunes Store Team show this error (Alpha channel) in watch app icons, when in previous versions they consider them correct. Lost time! Thank you Apple Inc!– MarkusSep 21, 2016 at 9:37
-
-
14With macOS High Sierra, Preview seems to save PNGs always WITH an alpha channel, even if the checkbox is unchecked. If I open the saved file, the info box always says "Has Alpha: 1". The sips tool also tells me
hasAlpha: yes
. Plus, iTunes Store complains about the unwanted alpha channel ("Operation Failed – The App Store icon … can't be transparent nor contain an alpha channel").– StefanOct 15, 2017 at 19:57 -
3As mentioned by @Psychomentally, ImageMagick finally worked for me:
convert in.png -alpha off out.png
. Re. Preview: switching "alpha" on/off in the export dialog changes the predicted file size, but saving always writes the file with alpha information (and corresponding size).– StefanNov 3, 2017 at 18:56
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
-
2
-
4If you change
-alpha remove -alpha off $i;
to-alpha remove -alpha off png24:$i;
it will output a 24bit png Feb 29, 2020 at 4:40 -
Your suggestion broke Xcode and now I can't run my command line script to build all of my targets because of what this install overwrote. The imagemagik install took a long time and installed a ton of stuff that I now have to remove. Can you show a few command lines that I can use to remove all of what I just installed? Jan 11 at 20:02
-
I like the command line option. But
ls *.png
seems unnecessarily fragile, and will do unexpected things if filenames contain spaces. Would it not be better to dofor i in *.png
? For the same reason, you should also double-quote both instances of "$i" in the convert command. Apr 11 at 9:21
Assuming you don't have another image editor, then you can open it in Preview on your Mac, and use the Export option to resave it in a different format- to ensure you get rid of the alpha channel, it might be best to export to JPG (best quality), then open that and export it as a PNG again.
Having said that, I suspect you're probably OK submitting an icon with a transparency channel as long as there's no actual transparency.
-
13This will result in a small amount of quality loss, and also a larger PNG file as the PNG format isn't suitable compressing the sort of artifacts you get when producing a JPG file. In addition Apple does reject PNG images with alpha channels even if there's no actual transparency. Jul 21, 2016 at 8:52
-
-
19You can actually just uncheck the "Alpha" checkbox while exporting to PNG. No need to export to JPG first. Nov 1, 2018 at 19:09
-
How to do operation on image data to reduce image channels from 4 to 3?– WW00WWJan 26, 2019 at 12:00
-
8Any PNGs with a transparency channel will not be accepted, no matter if transparency shows in image or not.– ganskiApr 8, 2019 at 21:25
If you are using the Preview app, there's no need to export then re-export between jpg and png, just choose export and below the filetype (PNG) you will see an alpha checkbox, unset it and save.
-
6I used to use this method, but on MacOS High Sierra, unchecking Alpha in Preview doesn't do anything unless you choose JPG as the output. If I try to open a PNG, Export PNG w/o Alpha, and open the new PNG, it has an Alpha channel. Oct 26, 2017 at 0:44
-
2
You can try imagemagick (also easily resize for different sizes):
convert in.png -background black -alpha remove -alpha off -resize 1024x1024 out.png
-
-
Marlhexs-MacBook-Pro:Edgar marlhex$ ls LUNCH SCREEN.jpg nuevo icon-5.png LUNCH SCREEN.png nuevo icon-51024 copy.jpg nuevo icon-5.jpg nuevo icon-51024.png Marlhexs-MacBook-Pro:Edgar marlhex$ nuevo icon-51024.png -bash: nuevo: command not found– MarlhexOct 30, 2019 at 18:57
There's no need to export the image to jpg first. You can uncheck the checkbox for the alpha channel and export directly from a png to a png without alpha channel in the preview app.
Just got the the following error when trying to upload my app to the iTunes app store:
iTunes Store Operations Failed
ERROR ITMS-90717: "Invalid App Store Icon. The App Store icon in the asset catalog in 'MyApp.app' can't be transparent nor contain an alpha channel."
I confirmed that my app store icons did include the alpha channel by locating the asset in Finder and looking up its info (⌘+i). Underneath More info, it showed:
Alpha channel: Yes
Found the solution above to use Preview to remove the alpha channel by exporting it with the Alpha checkbox unchecked, but figured a way to batch export them since I had 18 assets I needed to strip the alpha channel from.
The way I got batch exporting to work was to select all my app icon assets in finder > right click > open (or open with preview)
All of the assets will now appear in the same window. Select all (⌘+a), and then select File > Export Selected Images… > Expand Options > uncheck the Alpha checkbox > Choose (your destination folder)
Done! All your images are now exported with the alpha channel stripped off.
-
1I tried the same but it is not working anymore on High Sierra. Alpha channels are not removed on Preview.– SatheeshDec 19, 2017 at 9:54
-
1
-
1
To remove alpha channel from png:
on Mac: Preview version 9.0 (macOS Sierra) can remove the alpha channel if you export or save the image.
Preview version 10.0 (944.2) (macOS High Sierra) does not remove the alpha channel. Both Export and/or Save does not remove the alpha channel from the image.
-
3This highlights 2 recent facepalm issues by Apple.... High Sierra ignoring a save option AND the reason many people are here, Xcode suddenly can't upload apps because of icon transparency Dec 6, 2017 at 15:40
Well, since you're on a Mac, next time you probably just want to use Automator. Convert the image to BMP (lossless) and back to PNG. Let it save and voila...
I put Nikita Pushkar's very nice solution into a shell script that converts all iOS icons found in res/icon/ios
:
It uses brew to install imagemagick if not available, so I guess it will run only on Mac.
#! /usr/bin/env bash
#
# remove alpha channel from PNG images when App Store upload fails
#
# taken from https://stackoverflow.com/a/52962485 - @Nikita Pushkar
#
# make sure to have brew installed, see https://brew.sh:
# /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
#
# make sure to have imagemagick installed, see https://imagemagick.org:
# brew install imagemagick
#
if command -v convert; then
echo "imagemagick seems to be installed"
else
echo "imagemagick not installed, trying to install ..."
if command -v brew; then
echo "brew is installed, using it"
else
echo "brew not installed, trying to install ..."
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
fi
brew install imagemagick
fi
for i in `ls res/icon/ios/*.png`;
do
echo "convert $i"
convert $i -background white -alpha remove -alpha off $i;
done