Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kaishin/ImageScout
A Swift implementation of fastimage. Supports PNG, GIF, and JPEG.
https://github.com/kaishin/ImageScout
carthage cocoapods fastimage image-processing swift swiftpm
Last synced: 4 days ago
JSON representation
A Swift implementation of fastimage. Supports PNG, GIF, and JPEG.
- Host: GitHub
- URL: https://github.com/kaishin/ImageScout
- Owner: kaishin
- License: mit
- Created: 2014-10-11T11:57:09.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2019-11-30T17:33:33.000Z (about 5 years ago)
- Last Synced: 2024-12-01T07:06:37.698Z (12 days ago)
- Topics: carthage, cocoapods, fastimage, image-processing, swift, swiftpm
- Language: Swift
- Size: 1.02 MB
- Stars: 974
- Watchers: 21
- Forks: 74
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-ios - ImageScout - A Swift implementation of fastimage. Supports PNG, GIF, and JPEG. (Media / Image)
- awesome-swift - ImageScout - Implementation of [fastimage](https://pypi.org/project/fastimage/0.2.1/) - supports PNG, GIF, and JPEG. (Libs / Images)
- awesome-swift - ImageScout - Implementation of [fastimage](https://pypi.org/project/fastimage/0.2.1/) - supports PNG, GIF, and JPEG. (Libs / Images)
- awesome-ios-star - ImageScout - A Swift implementation of fastimage. Supports PNG, GIF, and JPEG. (Media / Image)
- fucking-awesome-swift - ImageScout - Implementation of 🌎 [fastimage](pypi.org/project/fastimage/0.2.1/) - supports PNG, GIF, and JPEG. (Libs / Images)
- awesome-swift-cn - ImageScout - a Swift implementation of [fastimage](https://pypi.python.org/pypi/fastimage/0.2.1) - supports PNG, GIF, and JPEG. (Libs / Images)
- awesome-swift - ImageScout - A Swift implementation of fastimage. Supports PNG, GIF, and JPEG. ` 📝 2 years ago ` (Images [🔝](#readme))
README
# ImageScout
![Test](https://github.com/kaishin/ImageScout/workflows/Test/badge.svg)
[![GitHub release](https://img.shields.io/github/release/kaishin/ImageScout.svg)](https://github.com/kaishin/ImageScout/releases/latest)
![Swift 5.0](https://img.shields.io/badge/Swift-5.0-orange.svg) ![platforms](https://img.shields.io/badge/platforms-iOS%20%7C%20macOS-lightgrey.svg)**ImageScout** is a Swift implementation of [fastimage](https://pypi.python.org/pypi/fastimage/0.2.1).
It allows you to find the size and type of a remote image by downloading as little as possible.#### Why?
Sometimes you need to know the size of a remote image before downloading it, such as
using a custom layout in a `UICollectionView`.#### How?
ImageScout parses the image data as it is downloaded. As soon as it finds out the size and type of image,
it stops the download. The downloaded data is below 60 KB in most cases.#### Install
#### Swift Package Manager
Add the following to your `Package.switft` file:
```swift
let package = Package(
dependencies: [
.package(url: "https://github.com/kaishin/ImageScout.git", from: "2.1.0")
],
)
```
#### [Carthage](https://github.com/Carthage/Carthage)- Add the following to your Cartfile: `github "kaishin/ImageScout"`
- Then run `carthage update`
- Follow the current instructions in [Carthage's README][carthage-installation]
for up to date installation instructions.[carthage-installation]: https://github.com/Carthage/Carthage#adding-frameworks-to-an-application
#### [CocoaPods](http://cocoapods.org)
- Add the following to your [Podfile](http://guides.cocoapods.org/using/the-podfile.html): `pod 'ImageScout'`
- You will also need to make sure you're opting into using frameworks: `use_frameworks!`
- Then run `pod install` with CocoaPods 1.0 or newer.#### Usage
The only method you will be using is `scoutImageWithURI()`, with the following full signature:
```swift
func scoutImageWithURI(URI: String, completion: (NSError?, CGSize, ScoutedImageType) -> ())
```Here's an example:
```swift
let scout = ImageScout()scout.scoutImageWithURI("http://.../image-scout-logo.png") { error, size, type in
if let error = error {
print(error.code)
} else {
print("Size: \(size)")
print("Type: \(type.rawValue)")
}
}
```If the image is not successfully parsed, the size is going to be `CGSizeZero` and the type `.Unsupported`. The error will contain more info about the reason:
- Error code **100**: Invalid URI parameter.
- Error code **101**: Image is corrupt or malformatted.
- Error code **102**: Not an image or unsopported image format URL.⚠️ *It's important to keep a strong reference to the `ImageScout` instance until the callback completes. If reference is lost, your completion handler will never be executed.*
#### Compatibility
- Swift 5 / Xcode 11
- iOS 8+
- macOS 10.11#### License
See LICENSE.