{"id":28559036,"url":"https://github.com/sdwebimage/sdwebimageavifcoder","last_synced_at":"2025-06-10T08:35:59.173Z","repository":{"id":34644916,"uuid":"181338601","full_name":"SDWebImage/SDWebImageAVIFCoder","owner":"SDWebImage","description":"A SDWebImage coder plugin to support AVIF(AV1 Image File Format) image","archived":false,"fork":false,"pushed_at":"2023-12-14T08:06:55.000Z","size":4946,"stargazers_count":61,"open_issues_count":7,"forks_count":14,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-06-04T04:11:08.319Z","etag":null,"topics":["av1","avif","carthage","cocoapods","ios","macos","sdwebimage"],"latest_commit_sha":null,"homepage":"","language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SDWebImage.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2019-04-14T16:37:46.000Z","updated_at":"2025-05-16T10:51:30.000Z","dependencies_parsed_at":"2024-01-29T10:09:35.337Z","dependency_job_id":"6d817ff8-36ae-4a95-b7dd-e3180b3d82f3","html_url":"https://github.com/SDWebImage/SDWebImageAVIFCoder","commit_stats":{"total_commits":184,"total_committers":10,"mean_commits":18.4,"dds":0.5217391304347826,"last_synced_commit":"f784fcf7be9e02ec2fb16028d44f5889bbb4cfe9"},"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SDWebImage%2FSDWebImageAVIFCoder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SDWebImage%2FSDWebImageAVIFCoder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SDWebImage%2FSDWebImageAVIFCoder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SDWebImage%2FSDWebImageAVIFCoder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SDWebImage","download_url":"https://codeload.github.com/SDWebImage/SDWebImageAVIFCoder/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SDWebImage%2FSDWebImageAVIFCoder/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259039543,"owners_count":22796853,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["av1","avif","carthage","cocoapods","ios","macos","sdwebimage"],"created_at":"2025-06-10T08:35:57.385Z","updated_at":"2025-06-10T08:35:59.134Z","avatar_url":"https://github.com/SDWebImage.png","language":"Objective-C","readme":"# SDWebImageAVIFCoder\n\n[![Build Status](https://github.com/SDWebImage/SDWebImageAVIFCoder/actions/workflows/check-image-decoding.yml/badge.svg)](https://github.com/SDWebImage/SDWebImageAVIFCoder/actions/workflows/check-image-decoding.yml)\n[![Version](https://img.shields.io/cocoapods/v/SDWebImageAVIFCoder.svg?style=flat)](https://cocoapods.org/pods/SDWebImageAVIFCoder)\n[![License](https://img.shields.io/cocoapods/l/SDWebImageAVIFCoder.svg?style=flat)](https://cocoapods.org/pods/SDWebImageAVIFCoder)\n[![Platform](https://img.shields.io/cocoapods/p/SDWebImageAVIFCoder.svg?style=flat)](https://cocoapods.org/pods/SDWebImageAVIFCoder)\n[![SwiftPM compatible](https://img.shields.io/badge/SwiftPM-compatible-brightgreen.svg?style=flat)](https://swift.org/package-manager/)\n[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/SDWebImage/SDWebImageAVIFCoder)\n\n## What's for\n\nThis is a [SDWebImage](https://github.com/rs/SDWebImage) coder plugin to add [AV1 Image File Format (AVIF)](https://aomediacodec.github.io/av1-avif/) support. Which is built based on the open-sourced [libavif](https://github.com/AOMediaCodec/libavif) codec.\n\nThis AVIF coder plugin support AVIF still/sequence image. Including alpha channel, as well as 10bit/12bit/16bit HDR images. (The AVIF sequence animation is available from v0.9.0).\n\nThe AVIF encoding is also supported now. Which always encode as 8-bit depth images.\n\nSee the demo for the more showcase.\n\n## Note\n\nAVIF image spec is still in evolve. And the current upstream AVIF codec is a simple implementation. The encoding time may be long for large images.\n\nSince we rely on the external codec libavif. We may periodically update the dependency and bump version. Make sure you're using the latest version as possible as you can :)\n\n## AV1 Codec\n\nlibavif is a image codec. But AVIF is based on the AV1 Video standard. So it need a AV1 codec for support. This relationship is just like HEIF(image) and HEVC(video) codec.\n\nYou can choose the codec and use `libavif` CocoaPods subspec to choose the one you'd like.\n\n### aom\n\n+ For Carthage/SwifftPM\n\nlibavif is built with [aom](https://aomedia.googlesource.com/aom/) codec support. aom is the first AV1 codec during the standard draft implementation. The aom support both decodinng and encoding\n\n+ For CocoaPods\n\nBecause of strange design of **subspec dependencies resolution algorithm**, we can not make aom by default (or all the subspecs will always link aom, which means not optional). So libavif is built with nothing codec (`libavif/core`). You need to choose the actual AV1 codec using one or more of below.\n\nIf you want to use aom, use:\n\n```ruby\npod 'libavif/liaom'\n```\n\nor other AV1 codec, like dav1d:\n\n```ruby\npod 'libavif/libdav1d'\n```\n\n### dav1d (Decoding)\n\n[dav1d](https://github.com/videolan/dav1d) is the new and next generation AV1 codec, focused on speed and correctness.\n\nSee more about [explanation for why starting a new project but not improving aom](https://github.com/videolan/dav1d#why-do-you-not-improve-libaom-rather-than-starting-a-new-project)\n\nFrom v0.3.0, libavif can built with dav1d. For CocoaPods user, you can simply use the subspec for this. Carthage for optional dav1d codec is not supported currently.\n\n### libgav1 (Decoding)\n\n[libgav1](https://chromium.googlesource.com/codecs/libgav1/) is a Main profile (0) \u0026 High profile (1) compliant AV1 decoder. More information on the AV1 video format can be found at aomedia.org.\n\nFrom v0.8.3, libavif can built with libgav1. For For CocoaPods user, you can simply use the subspec for this.\n\n### rav1e (Encoding)\n\n[rav1e](https://github.com/xiph/rav1e) is the fastest and safest AV1 encoder. Which use [Rust programming](https://www.rust-lang.org/) to provide fast and safe codec compared to aom. Its current form it is most suitable for cases where libaom (the reference encoder) is too slow.\n\nSee more about [performance](https://github.com/xiph/rav1e/issues/1248)\n\nFrom v0.4.3, libavif can built with rav1e. For CocoaPods user, you can simply use the subspec for this. Carthage/SPM for optional rav1c codec is not supported currently.\n\nNote: The librav1e on CocoaPods use pre-built static-linking binary. Which means, it can not be used for CocoaPods's dynamic-linking.\n\nTo use for framework package format (CocoaPods defaults use ar archive format), you should write something like this:\n\n```ruby\nuse_frameworks! :linkage =\u003e :static\n```\n\nbut not this:\n\n```ruby\nuse_frameworks!\n# use_frameworks! :linkage =\u003e :dynamic\n```\n\nNote: before librav1e v0.6.1, it only support iOS \u0026\u0026 macOS. watchOS and tvOS is avaiable from v0.6.2 with the latest Rust toolchain. And for visionOS supports need Rust community upstream support. For latest integration, check or fire issues in https://github.com/SDWebImage/librav1e-Xcode.\n\n### SVT-AV1 (Encoding)\n\n[SVT-AV1](https://gitlab.com/AOMediaCodec/SVT-AV1) is the Scalable Video Technology for AV1 (SVT-AV1 Encoder and Decoder) is an AV1-compliant encoder/decoder library core.\n\nFrom v0.8.3, libavif can built with STV-AV1. For For CocoaPods user, you can simply use the subspec for this.\n\n## Choose codec at runtime \n\nAlthough libavif has a automatic detection of installed AVIF codec, but for example, `aom` supports both decoding and encoding, but slower than `rav1e` on encoding.\n\nYou can force to use the `aom` for decoding and `rav1e` for encoding like this:\n\n+ Objective-C\n\n```objective-c\nNSDictionary *decodeOptions = [SDImageCoderAVIFDecodeCodecChoice: @(AVIF_CODEC_CHOICE_AOM)];\nNSDictionary *encodeOptions = [SDImageCoderAVIFEncodeCodecChoice: @(AVIF_CODEC_CHOICE_RAV1E)];\n\n// Pass from UI level options\n[imageView sd_setImageWithURL:url placeholderImage:nil options:0 context:@{SDWebImageContextImageDecodeOptions: decodeOptions, SDWebImageContextImageEncodeOptions: encodeOptions} progress:nil completed:nil];\n```\n\n+ Swift\n\n```swift\nlet decodeOptions: [SDImageCoderOption: Any] = [.avifDecodeCodecChoice: AVIF_CODEC_CHOICE_AOM.rawValue]\nlet encodeOptions = [SDImageCoderOption: Any] = [.avifEncodeCodecChoice: AVIF_CODEC_CHOICE_RAV1E.rawValue]\n\n// Pass from UI level options\nimageView.sd_setImage(with: url, placeholderImage: nil, options: [], context: [.imageDecodeOptions: decodeOptions, .imageEncodeOptions: encodeOptions], progress: nil, completed: nil)\n```\n\n## Requirements\n\n+ iOS 9\n+ macOS 10.11\n+ tvOS 9.0\n+ watchOS 2.0\n\n## Installation\n\n#### CocoaPods\nSDWebImageAVIFCoder is available through [CocoaPods](https://cocoapods.org). To install\nit with default aom AV1 codec, simply add the following line to your Podfile:\n\n```ruby\npod 'SDWebImageAVIFCoder'\n```\n\nNote: From version 0.4.0, if you want to use rav1e or dav1e instead aom for faster AV1 codec, control the subspec of libavif instead:\n\n```ruby\npod 'SDWebImageAVIFCoder'\npod 'libavif', :subspecs =\u003e [\n  'libdav1d',\n  'librav1e'\n]\n```\n\nor, for libgav1 \u0026\u0026 SVT-AV1, use:\n\n```ruby\npod 'SDWebImageAVIFCoder'\npod 'libavif', :subspecs =\u003e [\n  'libgva1',\n  'SVT-AV1'\n]\n```\n\nNote: From version 0.2.0, the dependency libavif and libaom use the portable C implementation to works on Apple platforms. If you need the pre-built library with SIMD/AVX and assembly optimization, try the 0.1.0 version. \n\n#### Carthage\n\nSDWebImageAVIFCoder is available through [Carthage](https://github.com/Carthage/Carthage).\n\n```\ngithub \"SDWebImage/SDWebImageAVIFCoder\"\n```\n\nCarthage does not support like CocoaPods' subspec, it only supports libaom for AVIF decoding \u0026\u0026 encoding.\n\n#### Swift Package Manager (Xcode 11+)\n\nSDWebImageAVIFCoder is available through [Swift Package Manager](https://swift.org/package-manager).\n\nThe framework through SwiftPM only supports libaom for AVIF decoding \u0026\u0026 encoding.\n\n```swift\nlet package = Package(\n    dependencies: [\n        .package(url: \"https://github.com/SDWebImage/SDWebImageAVIFCoder.git\", from: \"0.5\")\n    ]\n)\n```\n\n## Usage\n\nTo use AVIF coder, you should firstly add the `SDImageAVIFCoder.sharedCoder` to the coders manager. Then you can call the View Category method to start load AVIF images.\n\n+ Objective-C\n\n```objective-c\nSDImageAVIFCoder *AVIFCoder = SDImageAVIFCoder.sharedCoder;\n[[SDImageCodersManager sharedManager] addCoder:AVIFCoder];\nUIImageView *imageView;\n[imageView sd_setImageWithURL:url];\n```\n\n+ Swift\n\n```swift\nlet AVIFCoder = SDImageAVIFCoder.shared\nSDImageCodersManager.shared.addCoder(AVIFCoder)\nlet imageView: UIImageView\nimageView.sd_setImage(with: url)\n```\n\n### Decoding\n\n+ Objective-C\n\n```objective-c\n// AVIF image decoding\nNSData *avifData;\nUIImage *image = [[SDImageAVIFCoder sharedCoder] decodedImageWithData:avifData options:nil];\n```\n\n+ Swift\n\n```swift\n// AVIF image decoding\nlet avifData: Data\nlet image = SDImageAVIFCoder.shared.decodedImage(with: data, options: nil)\n```\n\n### Thumbnail Decoding (0.10.0+)\n\n+ Objective-C\n\n```objective-c\n// AVIF thumbnail image decoding\nNSData *avifData;\nCGSize thumbnailSize = CGSizeMake(300, 300);\nUIImage *thumbnailImage = [[SDImageAVIFCoder sharedCoder] decodedImageWithData:avifData options:@{SDImageCoderDecodeThumbnailPixelSize : @(thumbnailSize)}];\n```\n\n+ Swift\n\n```swift\n// AVIF thumbnail image decoding\nlet avifData: Data\nlet thumbnailSize = CGSize(width: 300, height: 300)\nlet image = SDImageAVIFCoder.shared.decodedImage(with: data, options: [.decodeThumbnailPixelSize: thumbnailSize])\n```\n\n### Encoding (No animtion support)\n\n+ Objective-c\n\n```objective-c\n// AVIF image encoding\nUIImage *image;\nNSData *avifData = [[SDImageAVIFCoder sharedCoder] encodedDataWithImage:image format:SDImageFormatAVIF options:nil];\n// Encode Quality\nNSData *lossyAVIFData = [[SDImageAVIFCoder sharedCoder] encodedDataWithImage:image format:SDImageFormatAVIF options:@{SDImageCoderEncodeCompressionQuality : @(0.1)}]; // [0, 1] compression quality\n```\n\n+ Swift\n\n```swift\n// AVIF image encoding\nlet image: UIImage\nlet avifData = SDImageAVIFCoder.shared.encodedData(with: image, format: .avif, options: nil)\n// Encode Quality\nlet lossyAVIFData = SDImageAVIFCoder.shared.encodedData(with: image, format: .avif, options: [.encodeCompressionQuality: 0.1]) // [0, 1] compression quality\n```\n\n## Screenshot\n\n\u003cimg src=\"https://raw.githubusercontent.com/SDWebImage/SDWebImageAVIFCoder/master/Example/Screenshot/AVIFDemo-iOS.png\" width=\"300\" /\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/SDWebImage/SDWebImageAVIFCoder/master/Example/Screenshot/AVIFDemo-macOS.png\" width=\"600\" /\u003e\n\nThe images are from [AV1 Still Image File Format Specification Test Files](https://github.com/AOMediaCodec/av1-avif/tree/master/testFiles).\n\n## AVIF Image Viewer\n\nAVIF is a new image format, which lack of related toolchains like Browser or Desktop Viewer support.\n\nYou can try [AVIFQuickLook](https://github.com/dreampiggy/AVIFQuickLook) QuickLook plugin on macOS to view it in Finder.\n\nYou can also try using [avif.js](https://kagami.github.io/avif.js/) to view it online by using Chrome's AV1 codec.\n\n## Testing\n\nSDWebImageAVIFCoder use [GitHub Actions](https://github.com/SDWebImage/SDWebImageAVIFCoder/actions) for testing. Each merge request will run the test cases to ensure the AVIF decoding/encoding function works.\n\nCurrent test cases use macOS command line tools, to compare the AVIF sample decoding result with [ImageMagick](https://www.imagemagick.org/).\n\nWe have also the XCTest unit test target, you can run it by using Xcode's Test action.\n\n## Author\n\nDreamPiggy, lizhuoli1126@126.com\n\n## Contributor\n\n[ledyba-z](https://github.com/ledyba-z), ryo.hirafuji@gmail.com\n\n## License\n\nSDWebImageAVIFCoder is available under the MIT license. See the LICENSE file for more info.\n\n## Thanks\n\n+ [libavif](https://github.com/AOMediaCodec/libavif)\n+ [aom](https://aomedia.googlesource.com/aom/)\n+ [dav1d](https://github.com/videolan/dav1d)\n+ [AVIFQuickLook](https://github.com/dreampiggy/AVIFQuickLook)\n+ [avif.js](https://github.com/Kagami/avif.js)\n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsdwebimage%2Fsdwebimageavifcoder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsdwebimage%2Fsdwebimageavifcoder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsdwebimage%2Fsdwebimageavifcoder/lists"}