{"id":28559053,"url":"https://github.com/sdwebimage/sdwebimageheifcoder","last_synced_at":"2025-06-10T08:36:00.168Z","repository":{"id":39381280,"uuid":"132608351","full_name":"SDWebImage/SDWebImageHEIFCoder","owner":"SDWebImage","description":"A SDWebImage coder plugin to support HEIF image without Apple's Image/IO framework","archived":false,"fork":false,"pushed_at":"2021-03-28T06:45:18.000Z","size":44265,"stargazers_count":33,"open_issues_count":2,"forks_count":6,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-06-04T03:31:48.729Z","etag":null,"topics":["c","carthage","cocoapods","heif","ios","macos","objective-c","sdwebimage","tvos"],"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}},"created_at":"2018-05-08T12:50:45.000Z","updated_at":"2023-08-10T06:54:11.000Z","dependencies_parsed_at":"2022-09-20T01:44:05.197Z","dependency_job_id":null,"html_url":"https://github.com/SDWebImage/SDWebImageHEIFCoder","commit_stats":null,"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SDWebImage%2FSDWebImageHEIFCoder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SDWebImage%2FSDWebImageHEIFCoder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SDWebImage%2FSDWebImageHEIFCoder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SDWebImage%2FSDWebImageHEIFCoder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SDWebImage","download_url":"https://codeload.github.com/SDWebImage/SDWebImageHEIFCoder/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SDWebImage%2FSDWebImageHEIFCoder/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259039551,"owners_count":22796854,"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":["c","carthage","cocoapods","heif","ios","macos","objective-c","sdwebimage","tvos"],"created_at":"2025-06-10T08:35:58.994Z","updated_at":"2025-06-10T08:36:00.117Z","avatar_url":"https://github.com/SDWebImage.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SDWebImageHEIFCoder\n\n[![CI Status](https://img.shields.io/travis/SDWebImage/SDWebImageHEIFCoder.svg?style=flat)](https://travis-ci.org/SDWebImage/SDWebImageHEIFCoder)\n[![Version](https://img.shields.io/cocoapods/v/SDWebImageHEIFCoder.svg?style=flat)](https://cocoapods.org/pods/SDWebImageHEIFCoder)\n[![License](https://img.shields.io/cocoapods/l/SDWebImageHEIFCoder.svg?style=flat)](https://cocoapods.org/pods/SDWebImageHEIFCoder)\n[![Platform](https://img.shields.io/cocoapods/p/SDWebImageHEIFCoder.svg?style=flat)](https://cocoapods.org/pods/SDWebImageHEIFCoder)\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/SDWebImageHEIFCoder)\n[![codecov](https://codecov.io/gh/SDWebImage/SDWebImageHEIFCoder/branch/master/graph/badge.svg)](https://codecov.io/gh/SDWebImage/SDWebImageHEIFCoder)\n\n## 4.x compatibility\n\nSDWebImage 5.x change the custom image coder API. This `master` branch follow the `5.x` branch of SDWebImage. For 4.x compatibility HEIF coder support, checkout `4.x` branch.\n\n## What's for\n\nThis is a [SDWebImage](https://github.com/rs/SDWebImage) coder plugin to add [High Efficiency Image File Format (HEIF)](http://nokiatech.github.io/heif/index.html) support. Which is built based on the open-sourced [libheif](https://github.com/strukturag/libheif) codec.\n\nThis HEIF coder plugin currently support HEIF single/still image **decoding** as well as HEIC image **encoding**.\n\nThe decoding supports [HDR](https://en.wikipedia.org/wiki/High-dynamic-range_imaging) HEIF image with 10/12 bit depth (larger than normal 8 bit) as well.\n\nIt support iOS 9+/macOS 10.11+ device without the dependency of Apple's Image/IO framework.\n\nFor iOS 8+/macOS 10.10+, use version lower than 0.10.0.\n\n## Performance\n\nApple's Image/IO framework supports Hardware-Accelerated HEIF decoding (A9+ chip) and encoding on (A10+ chip). And provide a backup Software decoding and encoding on all iOS 11+/macOS 10.13+ devices.\n\nThis coder is used for backward-compatible solution. And the codec only do Software decoding / encoding, which is slower than Image/IO. So if possible, choose to use Image/IO (SDWebImage's built-in coder) firstly.\n\n## Requirements\n\n+ iOS 9.0\n+ tvOS 9.0\n+ macOS 10.11\n+ watchOS 2.0\n+ Xcode 11.0\n\n## Installation\n\n#### CocoaPods\nSDWebImageHEIFCoder is available through [CocoaPods](https://cocoapods.org). To install\nit, simply add the following line to your Podfile:\n\n```ruby\npod 'SDWebImageHEIFCoder'\n```\n\nSDWebImageHEIFCoder contains subspecs `libde265` \u0026 `libx265`. Which integrate the codec plugin for libheif to support HEIF image decoding/encoding.\n\nTo enable HEIF decoding, you should add `libde265` subspec:\n\n```ruby\npod 'SDWebImageHEIFCoder/libde265'\n```\n\nTo enable HEIF encoding, you should add `libx265` subspec:\n\n```ruby\npod 'SDWebImageHEIFCoder/libx265'\n```\n\nBy default will contains only `libde265` subspec for most people's usage. Using `libx265` encoding subspec only if you want HEIF encoding.\n\n#### Carthage\n\nSDWebImageHEIFCoder is available through [Carthage](https://github.com/Carthage/Carthage).\n\nCarthage does not support like CocoaPods' subspec, since most of user use HEIF decoding without x265 library. The framework through Carthage only supports libde265 for HEIF decoding.\n\n```\ngithub \"SDWebImage/SDWebImageHEIFCoder\"\n```\n\n#### Swift Package Manager (Xcode 11+)\n\nSDWebImageHEIFCoder is available through [Swift Package Manager](https://swift.org/package-manager).\n\nThe framework through SwiftPM only supports libde265 for HEIF decoding.\n\n```swift\nlet package = Package(\n    dependencies: [\n        .package(url: \"https://github.com/SDWebImage/SDWebImageHEIFCoder.git\", from: \"0.6\")\n    ]\n)\n```\n\n## Usage\n\n### Add Coder\n\nTo use HEIF coder, you should firstly add the `SDImageHEIFCoder.sharedCoder` to the coders manager. You can also detect the target platform compatibility for HEIF and choose add coder.\n\n+ Objective-C\n\n```objective-c\nif (@available(iOS 11.0, macOS 10.13, tvOS 11.0, *)) {\n    // These version supports Image/IO built-in decoding\n} else {\n    // Don't support HEIF decoding, add coder\n    SDImageHEIFCoder *HEIFCoder = [SDImageHEIFCoder sharedCoder];\n    [[SDImageCodersManager sharedManager] addCoder:HEIFCoder];\n}\n```\n\n+ Swift\n\n```swift\nif #available(iOS 11.0, macOS 10.13, tvOS 11.0, *) {\n    // These version supports Image/IO built-in decoding\n} else {\n    // Don't support HEIF decoding, add coder\n    let HEIFCoder = SDImageHEIFCoder.shared\n    SDImageCodersManager.shared.addCoder(HEIFCoder)\n}\n```\n\n### Loading\n\nThen you can call the View Category method to start load HEIF images.\n\n+ Objective-C\n\n```objective-c\nUIImageView *imageView;\n[imageView sd_setImageWithURL:url];\n```\n\n+ Swift\n\n```swift\nlet imageView: UIImageView\nimageView.sd_setImage(with: url)\n```\n\n### Decoding\n\n`SDImageHEIFCoder` currently supports decode the static HEIF images.\n\nNote HEIF sequence images(.heics) is not supported currently, only supported in built-in coder from SDWebImage for iOS 13+/macOS 10.15+, also supported by [Safari and WebKit](https://bugs.webkit.org/show_bug.cgi?id=197384).\n\n+ Objective-C\n\n```objective-c\n// HEIF image decoding\nNSData *heifData;\nUIImage *image = [[SDImageHEIFCoder sharedCoder] decodedImageWithData:heifData options:nil];\n```\n\n+ Swift\n\n```swift\n// HEIF image decoding\nlet heifData: Data\nlet image = SDImageHEIFCoder.shared.decodedImage(with: data, options: nil)\n```\n\n### Thumbnail Decoding (0.7.0+)\n\nHEIF image container supports embed thumbnail image. If we can found a suitable thumbnail image, we pick that instead for quickly display, else we will decode full pixel image and scale down.\n\n+ Objective-C\n\n```objective-c\n// HEIF thumbnail image decoding\nNSData *heifData;\nCGSize thumbnailSize = CGSizeMake(300, 300);\nUIImage *thumbnailImage = [[SDImageHEIFCoder sharedCoder] decodedImageWithData:heifData options:@{SDImageCoderDecodeThumbnailPixelSize : @(thumbnailSize}];\n```\n\n+ Swift\n\n```swift\n// HEIF thumbnail image decoding\nlet heifData: Data\nlet thumbnailSize = CGSize(width: 300, height: 300)\nlet image = SDImageHEIFCoder.shared.decodedImage(with: data, options: [.decodeThumbnailPixelSize: thumbnailSize])\n```\n\n### Encoding\n\n`SDWebImageHEIFCoder` also support HEIF encoding (need x265 subspec). You can encode `UIImage` to HEIF compressed image data.\n\n+ Objective-C\n\n```objectivec\nUIImage *image;\nNSData *imageData = [image sd_imageDataAsFormat:SDImageFormatHEIF];\n// Encode Quality\nNSData *lossyData = [[SDImageHEIFCoder sharedCoder] encodedDataWithImage:image format:SDImageFormatHEIF options:@{SDImageCoderEncodeCompressionQuality : @(0.1)}]; // [0, 1] compression quality\nNSData *limitedData = [[SDImageHEIFCoder sharedCoder] encodedDataWithImage:image format:SDImageFormatHEIF options:@{SDImageCoderEncodeMaxFileSize : @(1024 * 10)}]; // v0.8.0 feature, limit output file size \u003c= 10KB\n```\n\n+ Swift\n\n```swift\nlet image;\nlet imageData = image.sd_imageData(as: .HEIF)\n// Encode Quality\nlet lossyData = SDImageHEIFCoder.shared.encodedData(with: image, format: .heif, options: [.encodeCompressionQuality: 0.1]) // [0, 1] compression quality\nlet limitedData = SDImageHEIFCoder.shared.encodedData(with: image, format: .heif, options: [.encodeMaxFileSize: 1024 * 10]) // v0.8.0 feature, limit output file size \u003c= 10KB\n```\n\n### Thumbnail Encoding (0.8.0+)\n\n+ Objective-C\n\n```objective-c\n// HEIF image thumbnail encoding\nUIImage *image;\nNSData *thumbnailData = [[SDImageHEIFCoder sharedCoder] encodedDataWithImage:image format:SDImageFormatHEIF options:@{SDImageCoderEncodeMaxPixelSize : @(CGSizeMake(200, 200)}, SDImageCoderEncodeEmbedThumbnail : @(YES)];\n// v0.8.0 feature, encoding max pixel size\n// v0.9.0 feature, control whether to embed thumbnail (max 320x320 pixels)\n```\n\n+ Swift\n\n```swift\n// HEIF image thumbnail encoding\nlet image: UIImage\nlet thumbnailData = SDImageHEIFCoder.shared.encodedData(with: image, format: .heif, options: [.encodeMaxPixelSize: CGSize(width: 200, height: 200), .encodeEmbedThumbnail : true])\n// v0.8.0 feature, encoding max pixel size\n// v0.9.0 feature, control whether to embed thumbnail (max 320x320 pixels)\n```\n\nSee more documentation in [SDWebImage Wiki - Coders](https://github.com/SDWebImage/SDWebImage/wiki/Advanced-Usage#custom-coder-420)\n\n## Screenshot\n\n\u003cimg src=\"https://raw.githubusercontent.com/SDWebImage/SDWebImageHEIFCoder/master/Example/Screenshot/HEIFDemo.png\" width=\"300\" /\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/SDWebImage/SDWebImageHEIFCoder/master/Example/Screenshot/HEIFDemo-macOS.png\" width=\"600\" /\u003e\n\nThe images are from [HEIF official site example](http://nokiatech.github.io/heif/examples.html)\n\n## Author\n\nDreamPiggy, lizhuoli1126@126.com\n\n## License\n\nSDWebImageHEIFCoder itself is available under the MIT license. See the LICENSE file for more info.\nHowever, when using `libx265`, the license will be subject to GPL licence (or commercial licence if you have one). Check [x265.org](http://x265.org/) for more information.\n\n## Thanks\n\n+ [libheif](https://github.com/strukturag/libheif)\n+ [libde265](https://github.com/strukturag/libde265)\n+ [libx265](https://bitbucket.org/multicoreware/x265)\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsdwebimage%2Fsdwebimageheifcoder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsdwebimage%2Fsdwebimageheifcoder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsdwebimage%2Fsdwebimageheifcoder/lists"}