删除图像中的alpha通道

时间:2023-01-15 00:22:05

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.

我有一个iOS的app图标,但是苹果不允许alpha出现在图片中。如何移除这个alpha通道?我只有png图像,我没有源文件,因为我的朋友为我做了图像。

9 个解决方案

#1


26  

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.

假设你没有另一个图像编辑器,你可以打开它在你的Mac预览,并使用导出选项重新保存在不同的格式——确保你摆脱alpha通道,最好向JPG出口(质量),然后打开,并将其导出为一个PNG。

Having said that, I suspect you're probably OK submitting an icon with a transparency channel as long as there's no actual transparency.

说了这么多,我想只要没有实际的透明度,你就可以用透明通道提交一个图标。

#2


99  

The accepted answer to export to JPG, then back to PNG is not recommended.

不建议导出到JPG,然后返回到PNG。

  • It's an extra step in the process (2 exports)
  • 这是过程中的一个额外步骤(2导出)
  • JPG is lossy, so you will lose some image data
  • JPG是有损的,所以会丢失一些图像数据

Here's a super fast and easy way to do this without the extra export or saving to (lossy) JPG:

这里有一个超级快速和简单的方法,不需要额外的导出或保存到(有损)JPG:

Using Preview app (Mac):

使用预览应用程序(Mac):

  1. Open the image
  2. 打开图片
  3. Command-Shift-S to Duplicate (creates a copy)
  4. 复制命令移位- s(创建副本)
  5. Command-S to Save
  6. 命令来保存
  7. Deselect the "Alpha" checkbox
  8. 取消选择“阿尔法”复选框
  9. 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
    • 这将覆盖您的原件,如果您想保留原件,只需在名称中保留“copy”即可
  10. 从文件名中删除“copy”(包括空格)这将覆盖您的原始文件,如果您想保留原始文件,只需在名称中保留“copy”即可
  11. Save
  12. 保存
  13. Click 'Replace' to confirm you want to overwrite the original
    • Only necessary if you are overwriting your original
    • 只有当你重写你的原作时才有必要
  14. 单击“替换”以确认您只在重写原始代码时需要重写原始代码

#3


26  

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.

如果您使用的是预览应用程序,则无需导出,然后在jpg和png之间进行再导出,只需选择导出,然后在filetype (png)下面,您将看到一个alpha复选框,取消设置并保存。

#4


9  

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.

不需要先将图片导出到jpg。您可以取消选中alpha通道的复选框,并在预览应用程序中直接从png导出到png,而没有alpha通道。

删除图像中的alpha通道

#5


8  

You can try imagemagick (also easily resize for different sizes):

您可以尝试imagemagick(也很容易调整大小):

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

#6


3  

Just got the the following error when trying to upload my app to the iTunes app store:

刚刚在尝试上传我的app到iTunes app store时出现以下错误:

iTunes Store Operations Failed

iTunes商店操作失败

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

错误ITMS-90717:“应用商店图标无效。”App Store图标在“MyApp”的资产目录中。app不能透明也不能包含alpha通道

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:

我证实我的应用程序商店图标包括阿尔法通道通过定位在Finder中资产并查找其信息(⌘+ I)。在更多的信息下面,它显示:

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.

找到上面的解决方案,使用预览来删除alpha通道,通过对alpha复选框进行无限制的导出,但是我找到了一种方法来批量导出它们,因为我有18个资产,我需要去掉alpha通道。

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)

批量导出的方法是在finder >中选择我的app图标资产右键点击>打开(或打开预览)

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.

完成了!现在,您的所有映像都被导出,去掉了alpha通道。

#7


3  

To remove alpha channel from png:

从png中移除alpha通道:

on Mac: Preview version 9.0 (macOS Sierra) can remove the alpha channel if you export or save the image.

在Mac上:预览版9.0 (macOS Sierra)可以删除alpha通道,如果您导出或保存图像。

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.

预览版10.0 (944.2)(macOS High Sierra)没有删除alpha通道。导出和/或保存都不会从映像中删除alpha通道。

#8


0  

the alpha check box is no longer there in preview

alpha复选框不在预览中

#9


0  

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

既然你用的是Mac,下次你可能只想用Automator。将图像转换为BMP(无损)并返回到PNG。让它保存,然后……

#1


26  

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.

假设你没有另一个图像编辑器,你可以打开它在你的Mac预览,并使用导出选项重新保存在不同的格式——确保你摆脱alpha通道,最好向JPG出口(质量),然后打开,并将其导出为一个PNG。

Having said that, I suspect you're probably OK submitting an icon with a transparency channel as long as there's no actual transparency.

说了这么多,我想只要没有实际的透明度,你就可以用透明通道提交一个图标。

#2


99  

The accepted answer to export to JPG, then back to PNG is not recommended.

不建议导出到JPG,然后返回到PNG。

  • It's an extra step in the process (2 exports)
  • 这是过程中的一个额外步骤(2导出)
  • JPG is lossy, so you will lose some image data
  • JPG是有损的,所以会丢失一些图像数据

Here's a super fast and easy way to do this without the extra export or saving to (lossy) JPG:

这里有一个超级快速和简单的方法,不需要额外的导出或保存到(有损)JPG:

Using Preview app (Mac):

使用预览应用程序(Mac):

  1. Open the image
  2. 打开图片
  3. Command-Shift-S to Duplicate (creates a copy)
  4. 复制命令移位- s(创建副本)
  5. Command-S to Save
  6. 命令来保存
  7. Deselect the "Alpha" checkbox
  8. 取消选择“阿尔法”复选框
  9. 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
    • 这将覆盖您的原件,如果您想保留原件,只需在名称中保留“copy”即可
  10. 从文件名中删除“copy”(包括空格)这将覆盖您的原始文件,如果您想保留原始文件,只需在名称中保留“copy”即可
  11. Save
  12. 保存
  13. Click 'Replace' to confirm you want to overwrite the original
    • Only necessary if you are overwriting your original
    • 只有当你重写你的原作时才有必要
  14. 单击“替换”以确认您只在重写原始代码时需要重写原始代码

#3


26  

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.

如果您使用的是预览应用程序,则无需导出,然后在jpg和png之间进行再导出,只需选择导出,然后在filetype (png)下面,您将看到一个alpha复选框,取消设置并保存。

#4


9  

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.

不需要先将图片导出到jpg。您可以取消选中alpha通道的复选框,并在预览应用程序中直接从png导出到png,而没有alpha通道。

删除图像中的alpha通道

#5


8  

You can try imagemagick (also easily resize for different sizes):

您可以尝试imagemagick(也很容易调整大小):

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

#6


3  

Just got the the following error when trying to upload my app to the iTunes app store:

刚刚在尝试上传我的app到iTunes app store时出现以下错误:

iTunes Store Operations Failed

iTunes商店操作失败

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

错误ITMS-90717:“应用商店图标无效。”App Store图标在“MyApp”的资产目录中。app不能透明也不能包含alpha通道

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:

我证实我的应用程序商店图标包括阿尔法通道通过定位在Finder中资产并查找其信息(⌘+ I)。在更多的信息下面,它显示:

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.

找到上面的解决方案,使用预览来删除alpha通道,通过对alpha复选框进行无限制的导出,但是我找到了一种方法来批量导出它们,因为我有18个资产,我需要去掉alpha通道。

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)

批量导出的方法是在finder >中选择我的app图标资产右键点击>打开(或打开预览)

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.

完成了!现在,您的所有映像都被导出,去掉了alpha通道。

#7


3  

To remove alpha channel from png:

从png中移除alpha通道:

on Mac: Preview version 9.0 (macOS Sierra) can remove the alpha channel if you export or save the image.

在Mac上:预览版9.0 (macOS Sierra)可以删除alpha通道,如果您导出或保存图像。

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.

预览版10.0 (944.2)(macOS High Sierra)没有删除alpha通道。导出和/或保存都不会从映像中删除alpha通道。

#8


0  

the alpha check box is no longer there in preview

alpha复选框不在预览中

#9


0  

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

既然你用的是Mac,下次你可能只想用Automator。将图像转换为BMP(无损)并返回到PNG。让它保存,然后……