IT박스

이미지에서 알파 채널 제거

itboxs 2020. 10. 20. 07:27
반응형

이미지에서 알파 채널 제거


iOS 용 앱 아이콘이 있지만 Apple은 이미지에 알파를 허용하지 않습니다. 이 알파 채널을 제거하는 방법? 나는 내 친구가 나를 위해 이미지를 한 것처럼 나는 소스 파일이 없습니다.


다른 이미지 편집기가 없다고 가정하면 Mac의 미리보기에서 열고 내보내기 옵션을 사용하여 다른 형식으로 다시 저장할 수 있습니다. 알파 채널을 제거하려면 내보내는 것이 가장 좋습니다. JPG (최고 품질)로 변환 한 다음이를 열고 다시 PNG로 내 보냅니다.

하지만 실제 투명성이없는 한 투명성 채널이있는 아이콘을 제출해도 괜찮을 것 같습니다.


JPG로 내 보낸 다음 다시 PNG로 내보내는 데 허용되는 답변은 권장되지 않습니다.

  • 프로세스의 추가 단계 (2 개 내보내기)
  • JPG는 손실이 있으므로 일부 이미지 데이터가 손실됩니다.

다음은 추가 내보내기 또는 (손실) JPG로 저장하지 않고도이 작업을 수행하는 매우 빠르고 쉬운 방법입니다.

미리보기 앱 사용 (Mac) :

  1. 이미지 열기
  2. Command-Shift-S to Duplicate (사본 생성)
  3. 저장할 Command-S
  4. "알파" 체크 상자 선택 해제
  5. 파일 이름 (공백 포함) 에서 "사본"삭제
    • 원본을 덮어 쓰고 원본을 유지하려면 이름에 "사본"만 남겨 두세요.
  6. 저장
  7. 원본을 덮어 쓸 것인지 확인 하려면 '교체'클릭하십시오.
    • 원본을 덮어 쓰는 경우에만 필요합니다. 알파 채널 제거

미리보기 앱을 사용하는 경우 jpg와 png 사이에서 내 보낸 다음 다시 내보낼 필요가 없습니다. 내보내기를 선택하면 파일 형식 (PNG) 아래에 알파 확인란이 표시되고 설정이 해제 된 후 저장됩니다.


아이콘이있는 디렉토리에서 모든 알파 채널을 제거해야하는 경우 다음 명령을 사용하십시오.

for i in `ls *.png`; do convert $i -background black -alpha remove -alpha off $i; done

Mac OS Mojave가 있고 "convert command not found"가있는 경우

brew install imagemagick

Homebrew를 설치하려면

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null

먼저 이미지를 jpg로 내보낼 필요가 없습니다. 알파 채널의 확인란을 선택 취소하고 미리보기 앱에서 알파 채널이없는 png에서 PNG로 직접 내보낼 수 있습니다.

여기에 이미지 설명 입력


imagemagick을 시도해 볼 수 있습니다 (다른 크기로 쉽게 크기 조정) :

convert in.png -background black -alpha remove -alpha off -resize 1024x1024 out.png

내 앱을 iTunes 앱 스토어에 업로드하려고 할 때 다음 오류가 발생했습니다.

iTunes Store 작업 실패

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.


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.


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...


the alpha check box is no longer there in preview


Nikita Pushkar의 매우 멋진 솔루션을 다음에서 찾은 모든 iOS 아이콘을 변환하는 쉘 스크립트에 넣었습니다 res/icon/ios.

사용할 수없는 경우 brew를 사용하여 imagemagick을 설치하므로 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

참고 URL : https://stackoverflow.com/questions/26171739/remove-alpha-channel-in-an-image

반응형