Skip to content

folio-sec/ImagePipeline

Repository files navigation

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

github "folio-sec/ImagePipeline"

Then run carthage update.

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

About

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

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages