Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
474 views
in Technique[技术] by (71.8m points)

ios - Xcode blowing up PNG size and ignoring Compress PNG = NO flag?

Currently, my Assets.xcassets folder is ~13MB with all images for my application. However, when I archive my app the Assets.car that results is closer to 33MB. When using iOSAssetExtractor as described here: What contributes to the size of assets in an IOS App and how can I shrink this? the issue appears to be that the PNGs are blowing up in size when they are "compressed" by Xcode. Many PNGs are 2-3x the size they were before going through the archiving process. This is a common problem that is referenced in multiple places.

The usual solution as referenced here: XCode png compression issue and here: https://imageoptim.com/xcode.html appears to be setting "Compress PNG Files" to No in build settings. This skips Xcode's unpacking and recompression of assets to avoid the asset size bloat that can be experienced. However, this doesn't appear to be working currently and might have stopped working in Xcode 7.3. There is a thread on this in the Apple forums here: https://forums.developer.apple.com/thread/43372 . However, the accepted solution appears to be changing the file type in the inspector to data which works for PNGs in a resources folder but does not appear to be an option for PNGs stored in an xcassets folder.

Note: I've also tried setting "Remove Text Metadata from PNG Files" to no as well with no success.

Can anyone recommend a solution for how to fix this issue in the current (7.3) version of Xcode so that my Assets.car file does not end up 2-3x larger than expected?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The specific problem of PNG sizes getting much larger seems to have been an Apple bug which appears to be addressed now. But, the more general problem of shrinking down each PNG to the smallest possible size is something that can still be solved more effectively. If you are interested in reading about a new delivery codec that can squeeze every last byte out of each PNG, then please have a look at this iOS framework.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...