为什么iOS应用程序包中的PNG图像比我的项目更大? [英] Why are PNG images larger in the iOS app bundle than in my project?

查看:93
本文介绍了为什么iOS应用程序包中的PNG图像比我的项目更大?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为iOS 6更新Hungry Helga(iPhone和iPad版本),我的新应用程序包存档中的所有PNG文件比我以前的版本大20%到40%。当然,这让我超过了50 MB的3G下载限制所以我真的想知道发生了什么。

I am in the process of updating Hungry Helga (iPhone and iPad versions) for iOS 6, and all of the PNG files in my new app bundle archives are between 20 and 40 percent larger than they were in my past releases. Of course, this is putting me over the 3G download limit of 50 MB so I'd really like to figure out what's going on.

我目前正在使用4.5版本的OSX 10.7.5上的Xcode。如果我没记错的话,以前的版本是用Xcode 4.2构建的。我尝试在构建设置中打开和关闭PNG压缩,但这对包中的图像大小没有影响。

I am currently using version 4.5 of Xcode on OSX 10.7.5. If I recall correctly the previous version was built with Xcode 4.2. I tried turning on and off PNG compression in the build settings but that had no effect on the image sizes in the bundle.

举一个具体的例子,我最大的PNG图像是1.9 MB作为源资产。旧应用程序包中为2.1 MB,新应用程序包中为2.5 MB。

To give a concrete example, my largest PNG image is 1.9 MB as a source asset. It is 2.1 MB in the old app bundle, and 2.5 MB in the new app bundle.

Apple是否改变了PNG压缩器的工作方式或者是否有可能的设置我失踪了什么?

Did Apple change the way the PNG compressor works or is there maybe a setting that I'm missing or something?

推荐答案

使用David H的脚本,我发现Xcode也将命令行参数-f 0传递给pngcrush。手册页指示-f 0将在压缩之前禁用任何IDAT过滤,这可能导致更大的PNG文件。从上面测试我的1.9 MB示例文件确认:

Using David H's script, I found that Xcode is also passing the command line parameter "-f 0" to pngcrush. The man page indicates that the "-f 0" will disable any IDAT filtering before compression which can result in a larger PNG file. Testing on my 1.9 MB example file from above confirms:

pngcrush -iphone in.png out.png 给出2.1 MB的结果我是寻找

pngcrush -iphone in.png out.png gives the 2.1 MB result that I am looking for

pngcrush -iphone -f 0 in.png out.png 产生不需要的2.5 MB结果

pngcrush -iphone -f 0 in.png out.png yields the undesired 2.5 MB result

现在的问题是:为什么Apple会改变这个?如果我解决它会以某种方式破坏图像加载吗?如果没有,Xcode中是否有这样的设置,或者我总是必须使用脚本来过滤掉-f 0参数?

Now the questions are: Why did Apple change this? Will it break image loading in some way if I work around it? If not, is there a setting for this in Xcode or will I always have to use a script to filter out the "-f 0" argument?

这篇关于为什么iOS应用程序包中的PNG图像比我的项目更大?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆