問題描述
如果我有一個包含大量圖像的 iPad 應用程序,那麼 PNG 仍然是最佳選擇嗎? (If I have an iPad app with lots of images, is PNG still the best option?)
我正在開發一個 iPad 應用程序,它有數百張照片質量的圖像。我自然會假設將這些圖像存儲為 JPEG,以優化應用程序文件的大小。但是,Apple 的指導方針指出:
對圖像使用 PNG 格式。PNG 格式提供無損圖像內容,這意味著將圖像數據保存為 PNG 格式然後將其讀回會產生完全相同的像素值。PNG 還具有優化的存儲格式,旨在更快地讀取圖像數據。它是 iOS 的首選圖像格式。
但是,如果我以 100% 的質量存儲與 JPEG 相同的圖像,它們的大小會下降到 PNG 無損版本的一半左右。
使用 JPEG 而不是 PNG 真的會對性能造成太大影響嗎?如果我以輪播或畫廊風格查看這些圖像,我真的需要擔心性能並改用 PNG 嗎?
謝謝!
參考解法
方法 1:
Regarding the quality PNG is good for application kind of images, but JPEG is preferred for photos. Choose the lowest JPEG quality that gives good enough quality for your images.
Regarding speed, size also matters. I have no IPad to test with, but the smaller file size to read from flash or network might very well out weight any additional decompression cost. The only way to find out is to measure on your actual device.
方法 2:
There is a performance consideration but while PNG is preferred for quality, given your application, I'd suggest JPEG would be preferable.
Pure performance isn't the only factor of interest or concern; an iPad has only a finite space available to it, and filling that up with image data that most users are not going to need or want seems preferable to using more computational power for most cases.
One other thing to consider ‑ on a gallery, you are strongly recommended to generate thumbnails which give you the best of both worlds: the smaller, more accessible image for general use and the full original image for 'best'.
If in doubt, benchmark with both and see how big the difference is in your application ‑ and if the difference is something you can live with versus the space saving, go with JPEG.
(by jowie、Albin Sunnanbo、Arantor)