Reputation: 3797
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.
Upvotes: 172
Views: 163145
Reputation: 1571
I've used a tool (anyone that allows to convert images to any format from any format). Here are the steps:
1. Transform all png images to jpeg
2. Transform the jpeg images back to png.
Try to upload a new build.
Upvotes: 2
Reputation: 1124
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
Upvotes: 95
Reputation: 3315
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
Upvotes: 4
Reputation: 4902
The accepted answer to export to JPG, then back to PNG is not recommended.
Here's a super fast and easy way to do this without the extra export or saving to (lossy) JPG:
Using Preview app (Mac):
Upvotes: 398
Reputation: 101
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.
Upvotes: 8
Reputation: 4619
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.
Upvotes: 10
Reputation: 793
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...
Upvotes: 3
Reputation: 6240
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.
Upvotes: 40
Reputation: 5451
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.
Upvotes: 18
Reputation: 649
You can try imagemagick (also easily resize for different sizes):
convert in.png -background black -alpha remove -alpha off -resize 1024x1024 out.png
Upvotes: 15
Reputation: 869
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.
Upvotes: 60