Xcode & wide gamut images

1.5k Views Asked by At

Some related questions around Display P3 (wide gamut) image handing:

  1. Is there a file name convention for wide gamut images, like there was for retina (@2x, @3x)?
  2. Is there a way to add wide gamut versions to xcassets?
  3. If we have have sRGB MyPic.png in our Xcode project, how do we use UIImage to load a P3 version?

Or...

  1. Should we simply replace our sRGB images with Display P3 images, and let older sRGB-based devices do their best to display them?
1

There are 1 best solutions below

1
On BEST ANSWER

The answers, from Apple, are here: https://developer.apple.com/videos/play/wwdc2016/712/ with PDF here: http://devstreaming.apple.com/videos/wwdc/2016/712ugi7vg8jznn3pc3u/712/712_working_with_wide_color.pdf

Some notes:

Photoshop:

  • Use Convert to Profile to convert to Display P3 profile
  • Don't use Assign Profile
  • Save for Web doesn't work with wide color.
  • Use Save As -> PNG from 16-bit source doc
  • Export assets as 16bit PNG files with embedded “Display P3” ICC profile

Xcode:

  • 16-bit PNGs can be dragged into XCAssets.
  • Xcode will auto-generate the 8-bit sRGB derivative (or you can supply it yourself)
  • UIImage will automatically load the correct image for your device's display.
  • App Slicing will cause only the correct images to be included in your app when downloading to a device.

Way more info in that WWDC session.

Naming:

  • There's no standard I could find, though Webkit's page of examples uses "-P3", e.g. "MyPic-P3.png". This'd be a useful convention if you want both types of file on a server.