Progressive Decoding

How to enable progressive decoding for JPEG and other formats

Enable progressive decoding with a single line of code. Nuke supports progressive JPEG out of the box, and WebP via a plugin built by the community.

Enable Decoding #

To enable1 progressive image decoding, set isProgressiveDecodingEnabled configuration option to true.

let pipeline = ImagePipeline {
    $0.isProgressiveDecodingEnabled = true
    
    // If `true`, the pipeline will store all of the progressively generated previews
    // in the memory cache. All of the previews have `isPreview` flag set to `true`.
    $0.isStoringPreviewsInMemoryCache = true
}

Nuke supports progressive JPEG out of the box.

See “Image Formats” to learn about other image formats supported by Nuke.

Display Progressively #

The pipeline will automatically do the right thing and deliver the progressive scans via progress closure as they arrive:

let imageView = UIImageView()
let task = ImagePipeline.shared.loadImage(
    with: url,
    progress: { response, _, _ in
        if let response = response {
            imageView.image = response.image
        }
    },
    completion: { result in
        // Display the final image
    }
)

Image View Extensions support progressive rendering out of the box.

  1. Progressive decoding is disabled by default to avoid wasting system resources.