https://github.com/gumob/imageextract
A Swift library to allows you to extract the size of an image without downloading.
https://github.com/gumob/imageextract
bitmap bytecode carthage image-processing scraping swift4
Last synced: 10 months ago
JSON representation
A Swift library to allows you to extract the size of an image without downloading.
- Host: GitHub
- URL: https://github.com/gumob/imageextract
- Owner: gumob
- License: mit
- Created: 2018-11-23T17:38:03.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2021-02-08T07:33:46.000Z (over 5 years ago)
- Last Synced: 2025-04-06T12:40:55.795Z (about 1 year ago)
- Topics: bitmap, bytecode, carthage, image-processing, scraping, swift4
- Language: Swift
- Homepage: https://gumob.github.io/ImageExtract/
- Size: 1.5 MB
- Stars: 6
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://github.com/gumob/ImageExtract)
[](https://travis-ci.com/gumob/ImageExtract)
[](https://codecov.io/gh/gumob/ImageExtract)
[](https://github.com/gumob/ImageExtract)



# ImageExtract
A Swift library to allows you to extract the size of an image without downloading.
## Requirements
ImageExtract supports multiple platforms
- iOS 10.0 or later
- macOS 10.11 or later
- Swift 5.0 or later
## Supported image format
- JPEG
- PNG
- GIF
- BMP
- WebP
## Installation
### Carthage
Add the following to your `Cartfile` and follow [these instructions](https://github.com/Carthage/Carthage#adding-frameworks-to-an-application).
```
github "gumob/ImageExtract"
```
Do not forget to include WebP.framework. Otherwise it will fail to build the application.

## Usage
Read the [usage](https://gumob.github.io/ImageExtract/usage.html) and the [API reference](https://gumob.github.io/ImageExtract/Classes/ImageExtract.html) for detailed information.
### Initialization
Just import ImageExtract framework:
```swift
import ImageExtract
```
### Synchronous and asynchronous request
Get the size of an image synchronously:
```swift
let url: String = "https://example.com/image.jpg"
let extractor: ImageExtract = ImageExtract()
let result: (size: CGSize, isFinished: Bool) = extractor.extract(url)
print(result.size) // (800.0, 600.0)
```
Get the size of an image asynchronously:
```swift
let url: String = "https://example.com/image.jpg"
let extractor: ImageExtract = ImageExtract()
extractor.extract(request) { (url: String?, size: CGSize, isFinished: Bool) in
print(size) // (800.0, 600.0)
}
```
## Copyright
ImageExtract is released under MIT license, which means you can modify it, redistribute it or use it however you like.