从 PHAsset 获取编辑过的照片 URL
Get an edited photo's URL from PHAsset
我正在尝试使用此代码从 PHAsset
获取照片的 URL。
let options: PHContentEditingInputRequestOptions = PHContentEditingInputRequestOptions()
options.canHandleAdjustmentData = {(adjustmeta: PHAdjustmentData) -> Bool in
return true
}
asset.requestContentEditingInput(with: options, completionHandler: { (contentEditingInput, info) in
guard let url = contentEditingInput?.fullSizeImageURL else {
observer.onError(PHAssetError.imageRequestFailed)
return
}
/// Using this `url`
})
大多数照片使用此代码都运行良好。
当我在相机应用程序中拍照并在照片应用程序中旋转照片时,然后 select 在我的应用程序中旋转的照片,此代码 returns 原始照片 URL -- 不是旋转版本。
如何从PHAsset
获取编辑后照片的本地URL?
尝试将您的 return 更改为“false”
If your block returns true, Photos provides the original asset data
for editing. Your app uses the adjustment data to alter, add to, or
reapply previous edits. (For example, an adjustment data may describe
filters applied to a photo. Your app reapplies those filters and
allows the user to change filter parameters, add new filters, or
remove filters.)
If your block returns false, Photos provides the most recent asset
data—the rendered output of all previous edits—for editing.
let options: PHContentEditingInputRequestOptions = PHContentEditingInputRequestOptions()
options.canHandleAdjustmentData = {(adjustmeta: PHAdjustmentData) -> Bool in
return false
}
asset.requestContentEditingInput(with: options, completionHandler: { (contentEditingInput, info) in
guard let url = contentEditingInput?.fullSizeImageURL else {
observer.onError(PHAssetError.imageRequestFailed)
return
}
/// Using this `url`
})
我正在尝试使用此代码从 PHAsset
获取照片的 URL。
let options: PHContentEditingInputRequestOptions = PHContentEditingInputRequestOptions()
options.canHandleAdjustmentData = {(adjustmeta: PHAdjustmentData) -> Bool in
return true
}
asset.requestContentEditingInput(with: options, completionHandler: { (contentEditingInput, info) in
guard let url = contentEditingInput?.fullSizeImageURL else {
observer.onError(PHAssetError.imageRequestFailed)
return
}
/// Using this `url`
})
大多数照片使用此代码都运行良好。
当我在相机应用程序中拍照并在照片应用程序中旋转照片时,然后 select 在我的应用程序中旋转的照片,此代码 returns 原始照片 URL -- 不是旋转版本。
如何从PHAsset
获取编辑后照片的本地URL?
尝试将您的 return 更改为“false”
If your block returns true, Photos provides the original asset data for editing. Your app uses the adjustment data to alter, add to, or reapply previous edits. (For example, an adjustment data may describe filters applied to a photo. Your app reapplies those filters and allows the user to change filter parameters, add new filters, or remove filters.)
If your block returns false, Photos provides the most recent asset data—the rendered output of all previous edits—for editing.
let options: PHContentEditingInputRequestOptions = PHContentEditingInputRequestOptions()
options.canHandleAdjustmentData = {(adjustmeta: PHAdjustmentData) -> Bool in
return false
}
asset.requestContentEditingInput(with: options, completionHandler: { (contentEditingInput, info) in
guard let url = contentEditingInput?.fullSizeImageURL else {
observer.onError(PHAssetError.imageRequestFailed)
return
}
/// Using this `url`
})