Skip to content

Latest commit

 

History

40 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nuke-Avif-Plugin

Swift Package Manager compatible

Nuke plugin for decoding AVIF images.

Requirements

  • iOS 15+
  • Xcode 16+ (Swift 6)
  • Nuke 13.x

Installation

Add the package to your Package.swift:

dependencies: [
    .package(url: "https://github.com/link-u/Nuke-Avif-Plugin.git", from: "1.0.0"),
]

Note: The formal 1.0.0 tag is not published yet. Until then, version resolution works with the pre-release tag 1.0.0-rc.2 (e.g. exact: "1.0.0-rc.2" or from: "1.0.0-rc.2").

Then add NukeAvifPlugin to your target dependencies:

.target(
    name: "YourTarget",
    dependencies: [
        .product(name: "NukeAvifPlugin", package: "Nuke-Avif-Plugin"),
    ]
)

In Xcode: File → Add Package Dependencies… and enter the repository URL.

Usage

Call AvifImageDecoder.enable() once at app launch (e.g. in AppDelegate or @main App init) before loading AVIF images:

import NukeAvifPlugin

AvifImageDecoder.enable()

After that, use Nuke as usual — AVIF URLs are decoded automatically via ImageDecoderRegistry.

To decode AVIF data manually:

let container = try AvifImageDecoder().decode(data)

YUV400 DeviceGray decoding (1.1.0)

From 1.1.0, eligible YUV400 AVIF is decoded on a dedicated monochrome 8bpp CGImage path by default (instead of the legacy YUV→ARGB path).

New-path conditions (all must hold):

  • yuvFormat == YUV400
  • depth == 8
  • no alpha (alphaPresent == false and alphaPlane == NULL)
  • transformFlags == AVIF_TRANSFORM_NONE (no irot / imir / clap / pasp)

Color space: CICP-based monochrome via createColorSpaceMonochrome(colorPrimaries:transferCharacteristics:). If that creation throws, the path falls back to CGColorSpaceCreateDeviceGray() so decode still succeeds (no ColorSpaceCache).

Default: AvifImageDecoder.yuv400DeviceGrayDecodingEnabled is ON. Apps that depend on the previous YUV→ARGB bitmap layout / color space (e.g. Glenwood, GanGanOnline, JumpPlus when they load eligible YUV400) will see a behavior change: 8bpp monochrome CGImage instead of converted RGB(A).

To opt out and keep the previous conversion path:

AvifImageDecoder.yuv400DeviceGrayDecodingEnabled = false

License

Nuke-Avif-Plugin is available under the MIT license. See the LICENSE file for more info.

About

Nuke's plugin that enables .avif display.

Resources

Stars

1 star

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages