Batch optimization of PNGs for iphone/ipad display as xcode does

后端 未结 7 1010

I\'m working on a magazine viewer for ipad and I\'m struggling with the performance.

I figured out that the most expensive part of displaying the pngs is the loading

相关标签:
7条回答
  • 2021-01-01 03:32

    I think I've found a good article about png optimization for iphone: http://iphonedevelopment.blogspot.com/2008/10/iphone-optimized-pngs.html

    It seams that xcode uses this command: /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/iphoneos-optimize

    It appears that the above command uses a modified version of pngcrush to optimize pngs and transform the color channels: /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/pngcrush -iphone -f 0 orig.png optimized.png

    And the optimization is really helpful. I've got 5 time faster image loading!

    0 讨论(0)
  • 2021-01-01 03:32

    We used Pngcrush to compress huge number of PNGs. You can try this too. And also if you don't need transparency then instead of PNG you can try JPG too. But you may go through a number of trial-and-error process for this, comparing the size and quality trade-off many times.

    0 讨论(0)
  • 2021-01-01 03:35

    I have been experimenting with pngnq, pngquant, pngcrush, optipng, etc.

    For my set of PNGs, I've achieved minimum file size with pngquant, pngnq and pngcrush

    Dir.glob("**/*.png").each do |file|
      ['pngnq -e .png -f', 'pngquant -f -speed 1 -ext .png', 'pngcrush'].each do |command|
        puts "#{command} #{file}"
        `#{command} #{file}`
      end
    end
    

    More details at: http://l4u.github.com/blog/2012/04/02/optimizing-file-sizes-of-png-images/

    0 讨论(0)
  • 2021-01-01 03:35

    Try http://texturepacker.com

    It can not only optimize PNGs but also reduce colors e.g. to RGBA4444 or RGB565 which decreases ping size dramatically and improves rendering on the devices.

    You could also export PVR files for devices that support it (e.g. iOS, some Android)

    And it also supports scaling down images for low res devices.

    0 讨论(0)
  • 2021-01-01 03:46

    I've lots and lots of space using pngnq, but I haven't done any testing to see if decoding the image slows it down at all.

    0 讨论(0)
  • 2021-01-01 03:49

    In my benchmark file size turned out to be more important than Xcode preprocessing (Xcode files were larger and slower to load).

    Best way to reduce PNG file size is to convert it to PNG8+alpha format — you can do that in batch with pngquant (or tweak manually with GUI).

    However, if in your case conversion from RGBA to premultiplied BGRA is what is taking the most time, then a fork of AdvanceCOMP with XCode proprietary extensions added will let you batch convert PNGs to iOS's native format.

    0 讨论(0)
提交回复
热议问题