Created
February 27, 2018 07:32
-
-
Save acalism/58a0a582d57fbd53d5d0b9352c6c6566 to your computer and use it in GitHub Desktop.
What is a live photo file?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import MobileCoreServices | |
if let t = UTTypeCreateAllIdentifiersForTag(kUTTagClassFilenameExtension, "mp4" as CFString, nil)?.takeRetainedValue() as? [CFString] { | |
print(t) | |
print(UTTypeConformsTo(t[0], kUTTypeMovie), "\n") | |
} | |
if let t = UTTypeCreateAllIdentifiersForTag(kUTTagClassMIMEType, "application/json" as CFString, nil)?.takeRetainedValue() as? [CFString] { | |
print(t) | |
print(UTTypeConformsTo(t[0], kUTTypeText), "\n") | |
} | |
if let t = UTTypeCopyPreferredTagWithClass(kUTTypeJPEG, kUTTagClassFilenameExtension)?.takeRetainedValue() { | |
print(t, "\n") | |
} | |
for uti in [kUTTypeJPEG, kUTTypeLivePhoto, kUTTypeMPEG, kUTTypeMPEG4, kUTTypePDF, kUTTypeJSON] { | |
if let d = UTTypeCopyDescription(uti)?.takeRetainedValue() { | |
print(d) | |
} | |
if let d = UTTypeCopyDeclaration(uti)?.takeRetainedValue() as? [String : Any] { | |
print(d) | |
} | |
print() | |
} | |
// kUTTypeLivePhoto has no file extension, and conforms to nobody | |
// https://stackoverflow.com/questions/32508375/apple-live-photo-file-format | |
// It contains both a JPEG and a quicktime MOV | |
print(UTTypeConformsTo(kUTTypeLivePhoto, kUTTypeImage)) // false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
关于 UTI(Uniform Type Identifiers),还有一篇文章的介绍比官方更好,
https://arstechnica.com/gadgets/2005/04/macosx-10-4/11/