RemoteImageSize
RemoteImageSize is a library to help you retrieve size from url
Requirements
- Xcode 10 or later
- iOS 9.0 or later
- Swift 5.0 or later
Features
- Get image size with specified GIF, PNG type from url synchronously, without downloading it.
- Get other image type by get data through URLSession
Getting Started
CocoaPods
Install with CocoaPods by adding the following to your Podfile
:
platform :ios, '9.0'
use_frameworks!
pod 'RemoteImageSize'
Swift Package Manager
Install with Swift Package Manager by adding the following to your Package.swift
:
dependencies: [
.package(url: "https://github.com/hoangtaiki/RemoteImageSize", from: "1.0.0"),
],
Usage
let remoteImageSize = RemoteImageSize()
Get size for specified image type
let remoteImageSize = RemoteImageSize()
let pngImageURL = URL(string: "https://i.imgur.com/vKYKUri.png")!
remoteImageSize.getImageSizeFromURL(pngImageURL, imageType: .png) { (size, error) in
guard let s = size else {
return
}
print("PNG image size = \(s)")
}
Get size for none specified image type
let remoteImageSize = RemoteImageSize()
let jpgImageURL = URL(string: "https://i.imgur.com/9gvybiS.jpg")!
remoteImageSize.getImageSizeFromURL(jpgImageURL) { (size, error) in
guard let s = size else {
return
}
print("JPG image size = \(s)")
}
Contributing
We’re glad you’re interested in RemoteImageSize, and we’d love to see where you take it. If you have suggestions or bug reports, feel free to send pull request or create new issue.
Thanks, and please do take it for a joyride!