xcode PNG优化的最佳实践?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2386643/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 19:10:17  来源:igfitidea点击:

Best practice for PNG optimization?

iphonexcodememory

提问by user287106

I 'd like to prepare my PNGs for the best optimization, so I can get the best image quality (lossless if possible) and the smallest size.

我想为我的 PNG 准备最佳优化,这样我就可以获得最佳图像质量(如果可能的话,无损)和最小尺寸。

From what I understand, I should use: PNG, 72 dpi, RGB, but what else?

据我了解,我应该使用:PNG、72 dpi、RGB,但还有什么?

Here is what we find in the iPhone HIG:

以下是我们在 iPhone HIG 中发现的内容:

Note:*The standard bit depth for icons and images is 24 bits (8 bits each for red, green, and blue), plus an 8-bit alpha channel. The PNG format is recommended, because it preserves color depth and supports an embedded alpha channel.

注意:*图标和图像的标准位深度为 24 位(红色、绿色和蓝色各 8 位),加上 8 位 Alpha 通道。推荐使用 PNG 格式,因为它保留了颜色深度并支持嵌入的 Alpha 通道。

I guess this mean we should save the image as PNG 24 and create them in 8 bits mode? But I also read about 32 bits for best quality ?

我想这意味着我们应该将图像保存为 PNG 24 并以 8 位模式创建它们?但我也读了大约 32 位以获得最佳质量?

The interlacing scheme (witch add to the file size) allows for the PNGs to display faster. Does this applies to the iPhone?

隔行扫描方案(女巫添加到文件大小)允许 PNG 显示得更快。这适用于iPhone吗?

Thanks.

谢谢。

回答by Kornel

I suggest using ImageAlpha(lossy) on as many images as you can, because it greatly reduces their size.

我建议在尽可能多的图像上使用ImageAlpha(有损),因为它大大减少了它们的大小。

Optimize all images with ImageOptim— it will remove all invisible junk and re-compress the data.

使用ImageOptim优化所有图像——它将删除所有不可见的垃圾并重新压缩数据。

Disable Xcode conversion, because it undoes other optimisations and can make images much slowerto load.

禁用 Xcode 转换,因为它会撤消其他优化并且会使图像加载速度变慢

回答by MrMage

24 bit is red, green and blue with 8 bits each. 32 bits is RGB plus an 8-bit alpha channel. So if you need (semi-)transparent images, you should go for 32bit PNG, otherwise 24bit.

24 位是红、绿、蓝各 8 位。32 位是 RGB 加上 8 位 alpha 通道。因此,如果您需要(半)透明图像,则应选择 32 位 PNG,否则为 24 位。

You don't have to compress/crush the PNGs yourself, Xcode's build steps will automatically use pngcrush and re-order the color channels for the iPhone's BGR memory alignment.

您不必自己压缩/粉碎 PNG,Xcode 的构建步骤将自动使用 pngcrush 并为 iPhone 的 BGR 内存对齐重新排序颜色通道。

回答by thierryb

For my background app I am using JPEG (Export for web in photoshop) with quality 70.

对于我的后台应用程序,我使用质量为 70 的 JPEG(在 photoshop 中导出为网络)。

Last day I heard about pngcrunch, tried it but file size is the same...

昨天我听说了 pngcrunch,试过了,但文件大小是一样的......

http://pmt.sourceforge.net/pngcrush/

http://pmt.sourceforge.net/pngcrush/

Take a look at this previous post : Understanding 24 bit PNG generated with Photoshop

看一下之前的帖子: 了解使用 Photoshop 生成的 24 位 PNG