v0.15: Live Photo 生产规则 — 平台限制、拼图版式、长视频处理、发布提醒、可见文案规则
新增 Live Photo 正式能力:单视频、二宫格、三宫格、四宫格、三连拼图、 长视频低成本诊断。增加 references/live-photo-production.md 生产规范、 scripts/ 工具链(contact sheet / .pvt 打包 / Apple metadata)、 validator R8 visual bounds + R9 title gap、文档约束测试。 由 Codex 完成主体实现。
This commit is contained in:
1 parent
032782ff67
commit
f492caeb8b
20 files changed
+1982
-22
No files matched your search
@@ -0,0 +1,44 @@
|
||||
import Foundation
|
||||
import ImageIO
|
||||
|
||||
guard CommandLine.arguments.count == 4 else {
|
||||
fputs("Usage: swift add-livephoto-maker-note.swift <input.jpg> <output.jpg> <asset-id>\n", stderr)
|
||||
exit(2)
|
||||
}
|
||||
|
||||
let inputURL = URL(fileURLWithPath: CommandLine.arguments[1])
|
||||
let outputURL = URL(fileURLWithPath: CommandLine.arguments[2])
|
||||
let assetIdentifier = CommandLine.arguments[3]
|
||||
|
||||
guard let source = CGImageSourceCreateWithURL(inputURL as CFURL, nil) else {
|
||||
fputs("Could not open input image\n", stderr)
|
||||
exit(1)
|
||||
}
|
||||
|
||||
guard let imageType = CGImageSourceGetType(source) else {
|
||||
fputs("Could not determine image type\n", stderr)
|
||||
exit(1)
|
||||
}
|
||||
|
||||
let imageCount = CGImageSourceGetCount(source)
|
||||
|
||||
guard let destination = CGImageDestinationCreateWithURL(outputURL as CFURL, imageType, imageCount, nil) else {
|
||||
fputs("Could not create output image\n", stderr)
|
||||
exit(1)
|
||||
}
|
||||
|
||||
for index in 0..<imageCount {
|
||||
var properties = (CGImageSourceCopyPropertiesAtIndex(source, index, nil) as? [String: Any]) ?? [:]
|
||||
var makerApple = (properties[kCGImagePropertyMakerAppleDictionary as String] as? [String: Any]) ?? [:]
|
||||
makerApple["17"] = assetIdentifier
|
||||
properties[kCGImagePropertyMakerAppleDictionary as String] = makerApple
|
||||
|
||||
CGImageDestinationAddImageFromSource(destination, source, index, properties as CFDictionary)
|
||||
}
|
||||
|
||||
guard CGImageDestinationFinalize(destination) else {
|
||||
fputs("Could not finalize output image\n", stderr)
|
||||
exit(1)
|
||||
}
|
||||
|
||||
print("Wrote Apple MakerNote asset identifier: \(assetIdentifier)")
|
||||
Reference in new issue
Block a user