As you know the iphone guidelines discourage loading uiimages that are greater than 1024x1024.
The size of the images that i would have to load varies, and i would l
In Swift 5, with ImageIO,
extension URL{
var sizeOfImage: CGSize?{
guard let imageSource = CGImageSourceCreateWithURL(self as CFURL, nil)
, let imageProperties = CGImageSourceCopyPropertiesAtIndex(imageSource, 0, nil) as? [AnyHashable: Any]
, let pixelWidth = imageProperties[kCGImagePropertyPixelWidth as String] as! CFNumber?
, let pixelHeight = imageProperties[kCGImagePropertyPixelHeight as String] as! CFNumber?
else {
return nil
}
var width: CGFloat = 0, height: CGFloat = 0
CFNumberGetValue(pixelWidth, .cgFloatType, &width)
CFNumberGetValue(pixelHeight, .cgFloatType, &height)
}
return CGSize(width: width, height: height)
}
}
imageProperties[kCGImagePropertyOrientation as String] may be nil.
It is nil, I tested with png image file
as Apple says
kCGImagePropertyOrientation
The numeric value for this key encodes the intended display orientation for the image according to the TIFF and Exif specifications.