Skip to content

Instantly share code, notes, and snippets.

@Willib
Created January 6, 2017 07:42
Show Gist options
  • Save Willib/68fc090a859e63c6b416cd7e082e3dcc to your computer and use it in GitHub Desktop.
Save Willib/68fc090a859e63c6b416cd7e082e3dcc to your computer and use it in GitHub Desktop.
iOS中判断一个URL是否为图片路径
private func imageToAssetURL(url: URL) -> URL?{
let pathExtention = url.pathExtension as CFString
let fileUIT = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, pathExtention, nil)?.takeRetainedValue()
if (UTTypeConformsTo(fileUIT!, kUTTypeImage)){
let param = CXEEngineInitParam()
let movieMaker = CXEImageToVideo(videoWidth:Int(param.sequence.width), videoHeight: Int(param.sequence.height))
let fileURL = movieMaker.createMovieFrom(url: url, duration: Int(CXPreparetValue.imageDuration))
return fileURL
}
return url
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment