Swiftpack.co - Package - folio-sec/ImagePipeline

Build Status codecov Carthage compatible MIT License

ImagePipeline

Folio Image Pipeline is an image loading and caching framework for iOS clients

Usage

let imagePipeline = ImagePipeline()
imagePipeline.shared.load(/* image URL */, into: /* image view */, transition: .fadeIn /* default is `.none`*/,
                          defaultImage: ..., failureImage: ...)

Example

override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
    let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) as! Cell

    ImagePipeline.shared.load(urls[indexPath.row % 200],
                              into: cell.imageView,
                              transition: .fadeIn,
                              defaultImage: UIImage(named: "loading")!,
                              failureImage: UIImage(named: "failed")!)
    
    return cell
}

Resize

Aspect Fit (Default)

let resizer = ImageResizer(targetSize: CGSize(width: 400, height: 400))
ImagePipeline.shared.load(/* imageURL */, into: /* image view */, processors: [resizer])

|Original|Resized| |:-:|:-:| |1|testimageresizeraspectfit 1|

Aspect Fill

let resizer = ImageResizer(targetSize: CGSize(width: 400, height: 400), contentMode: .aspectFill)
ImagePipeline.shared.load(/* imageURL */, into: /* image view */, processors: [resizer])

|Original|Resized| |:-:|:-:| |1|testimageresizeraspectfill 1|

Resize & Blur

let scale: CGFloat = 2
let size = CGSize(width: 375 * scale, height: 232 * scale)
let resizer = ImageResizer(targetSize: size, contentMode: .aspectFill)
let filter = BlurFilter(style: .light)

ImagePipeline.shared.load(/* imageURL */, into: /* image view */, processors: [resizer, filter])

|Original|Blurred| |:-:|:-:| |resize|testblurfilter 2|

TTL

ImagePipeline respects the max-age value of Cache-Control response header, and sets independent TTL for each image.

Supported content types

✅ PNG
✅ JPEG
✅ GIF
✅ WebP

Installation

Carthage

github "folio-sec/ImagePipeline"

Then run carthage update.

Follow the current instructions in Carthage's README for up to date installation instructions.

Github

link
Stars: 165

Used By

Total: 0

Releases

v1.0.0 - 2020-03-13 21:02:47

Fixed archiving failure when installing via SPM

v0.9.0 - 2020-03-12 20:01:52

Update to Swift 5 syntax

v0.8.6 - 2020-03-12 19:59:48

Update libwebpdecoder.a to the latest version

v0.8.5 - 2020-03-12 19:08:45

Add a callback closure interface

v0.8.4 - 2020-03-12 18:26:15

Support Swift Package Manager