Remove alpha channel in an image

前端 未结 13 1178
青春惊慌失措
青春惊慌失措 2020-12-12 15:10

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 fi

相关标签:
13条回答
  • 2020-12-12 16:10

    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
    
    0 讨论(0)
提交回复
热议问题