Nuke plugin for decoding AVIF images.
- iOS 15+
- Xcode 16+ (Swift 6)
- Nuke 13.x
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.0tag is not published yet. Until then, version resolution works with the pre-release tag1.0.0-rc.2(e.g.exact: "1.0.0-rc.2"orfrom: "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.
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)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 == YUV400depth == 8- no alpha (
alphaPresent == falseandalphaPlane == 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 = falseNuke-Avif-Plugin is available under the MIT license. See the LICENSE file for more info.