Code:
func getImageWidthFromURL() -> Int{
if let imageSource = CGImageSourceCreateWithURL(URL(string: post.thumbnail ?? "")! as CFURL, nil) {
if let imageProperties = CGImageSourceCopyPropertiesAtIndex(imageSource, 0, nil) as Dictionary? {
let pixelWidth = imageProperties[kCGImagePropertyPixelWidth] as! Int
return pixelWidth
}
}
return 300
}
Related Posts