Skip to content

Instantly share code, notes, and snippets.

@DimitarNestorov
Created February 16, 2025 17:06
Show Gist options
  • Select an option

  • Save DimitarNestorov/398c635551bbc5a70244e08711d501b3 to your computer and use it in GitHub Desktop.

Select an option

Save DimitarNestorov/398c635551bbc5a70244e08711d501b3 to your computer and use it in GitHub Desktop.
Generate a markdown table of supported image file formats in iOS
let sourceUTIs = CGImageSourceCopyTypeIdentifiers() as? [String] ?? []
let destinationUTIs = CGImageDestinationCopyTypeIdentifiers() as? [String] ?? []
var markdownTable = """
| UTI | File Extensions | Source | Destination | Notes |
| - | - | - | - | - |
"""
let allUTIs = Set(sourceUTIs).union(Set(destinationUTIs))
func fileExtension(for uti: String) -> String {
if let type = UTType(uti), let extensions = type.tags[.filenameExtension] {
return extensions.map { "`\($0)`" }.joined(separator: ", ")
}
return "N/A"
}
let sortedUTIs = allUTIs.sorted { uti1, uti2 in
let isPublic1 = uti1.hasPrefix("public.")
let isPublic2 = uti2.hasPrefix("public.")
let inSource1 = sourceUTIs.contains(uti1)
let inDest1 = destinationUTIs.contains(uti1)
let inSource2 = sourceUTIs.contains(uti2)
let inDest2 = destinationUTIs.contains(uti2)
let both1 = inSource1 && inDest1
let both2 = inSource2 && inDest2
if both1 != both2 {
return both1
}
if isPublic1 != isPublic2 {
return isPublic1
}
return uti1 < uti2
}
for uti in sortedUTIs {
let ext = fileExtension(for: uti)
let sourceCheck = sourceUTIs.contains(uti) ? "✅" : "❌"
let destinationCheck = destinationUTIs.contains(uti) ? "✅" : "❌"
markdownTable += "\n| `\(uti)` | \(ext) | \(sourceCheck) | \(destinationCheck) | |"
}
print(markdownTable)
@DimitarNestorov

DimitarNestorov commented Feb 16, 2025 •

Copy link
Copy Markdown
Author
UTI File Extensions Source Destination Notes
public.heic heic ✅ ✅
public.heics heics ✅ ✅
public.jpeg jpeg, jpg, jpe ✅ ✅
public.jpeg-2000 jp2, jpf, jpx, j2k, j2c ✅ ✅
public.pbm N/A ✅ ✅
public.png png ✅ ✅
public.pvr N/A ✅ ✅
public.tiff tiff, tif ✅ ✅
com.adobe.photoshop-image psd ✅ ✅
com.apple.atx N/A ✅ ✅
com.apple.icns icns ✅ ✅
com.compuserve.gif gif ✅ ✅
com.ilm.openexr-image exr ✅ ✅
com.microsoft.bmp bmp, dib ✅ ✅
com.microsoft.dds N/A ✅ ✅
com.microsoft.ico ico ✅ ✅
com.truevision.tga-image tga ✅ ✅
org.khronos.astc N/A ✅ ✅
org.khronos.ktx N/A ✅ ✅
org.khronos.ktx2 N/A ✅ ✅ iOS 16.0+
public.avci avci ✅ ❌
public.avif avif ✅ ❌ iOS 16.0+
public.avis N/A ✅ ❌ iOS 16.0+
public.heif heif, hif ✅ ❌
public.jpeg-xl jxl ✅ ❌ iOS 17.0+
public.mpo-image mpo ✅ ❌
public.radiance N/A ✅ ❌
com.adobe.pdf pdf ❌ ✅
com.adobe.raw-image dng ✅ ❌
com.canon.cr2-raw-image cr2 ✅ ❌
com.canon.cr3-raw-image cr3 ✅ ❌
com.canon.crw-raw-image crw ✅ ❌
com.canon.tif-raw-image tif ✅ ❌
com.dxo.raw-image dxo ✅ ❌
com.epson.raw-image erf ✅ ❌
com.fuji.raw-image raf ✅ ❌
com.hasselblad.3fr-raw-image 3fr ✅ ❌
com.hasselblad.fff-raw-image fff ✅ ❌
com.kodak.raw-image dcr ✅ ❌
com.konicaminolta.raw-image mrw ✅ ❌
com.leafamerica.raw-image mos ✅ ❌
com.leica.raw-image raw ✅ ❌
com.leica.rwl-raw-image rwl ✅ ❌
com.microsoft.cur N/A ✅ ❌
com.nikon.nrw-raw-image nrw ✅ ❌
com.nikon.raw-image nef ✅ ❌
com.olympus.or-raw-image orf ✅ ❌
com.olympus.raw-image orf ✅ ❌
com.olympus.sr-raw-image orf ✅ ❌
com.panasonic.raw-image raw ✅ ❌
com.panasonic.rw2-raw-image rw2 ✅ ❌
com.pentax.raw-image pef ✅ ❌
com.phaseone.raw-image iiq ✅ ❌
com.samsung.raw-image srw ✅ ❌
com.sony.arw-raw-image arw ✅ ❌
com.sony.axr-raw-image axr ✅ ❌ iOS 18.0+
com.sony.raw-image srf ✅ ❌
com.sony.sr2-raw-image sr2 ✅ ❌
org.webmproject.webp webp ✅ ❌

Unless noted otherwise the format is supported since at least iOS 14.3 (18C66)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment