{"id":15288647,"url":"https://github.com/iankoex/unifiedblurhash","last_synced_at":"2025-10-24T16:30:04.727Z","repository":{"id":147191903,"uuid":"577460925","full_name":"iankoex/UnifiedBlurHash","owner":"iankoex","description":"BlurHash Implementation for Swift on iOS, macOS, tvOS, watchOS, macCatalyst and visionOS.","archived":false,"fork":false,"pushed_at":"2023-11-25T20:15:51.000Z","size":118,"stargazers_count":30,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-13T08:09:49.083Z","etag":null,"topics":["blurhash","image","ios","macos","swift","swiftui"],"latest_commit_sha":null,"homepage":"","language":"Swift","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/iankoex.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}},"created_at":"2022-12-12T19:41:54.000Z","updated_at":"2025-01-31T17:15:20.000Z","dependencies_parsed_at":null,"dependency_job_id":"5e7e5881-fc07-4945-92fc-c971d1806f62","html_url":"https://github.com/iankoex/UnifiedBlurHash","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iankoex%2FUnifiedBlurHash","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iankoex%2FUnifiedBlurHash/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iankoex%2FUnifiedBlurHash/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iankoex%2FUnifiedBlurHash/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iankoex","download_url":"https://codeload.github.com/iankoex/UnifiedBlurHash/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248681491,"owners_count":21144700,"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":["blurhash","image","ios","macos","swift","swiftui"],"created_at":"2024-09-30T15:51:49.447Z","updated_at":"2025-10-24T16:30:04.721Z","avatar_url":"https://github.com/iankoex.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# UnifiedBlurHash\n\n[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fiankoex%2FUnifiedBlurHash%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/iankoex/UnifiedBlurHash)\n[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fiankoex%2FUnifiedBlurHash%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/iankoex/UnifiedBlurHash)\n[![Swift Build and Test](https://github.com/iankoex/UnifiedBlurHash/actions/workflows/swift.yml/badge.svg)](https://github.com/iankoex/UnifiedBlurHash/actions/workflows/swift.yml)\n\nExtensions of `UIImage` and `NSImage` to encode and decode blur hashes, based on [Wolt's Implementation](https://github.com/woltapp/blurhash) for Swift (iOS).\n\nBased on [Mortenjust's Implementation](https://github.com/mortenjust/Blurhash-macos.git) for macOS\n\nScreenshot\n\n![Screenshot](https://user-images.githubusercontent.com/30172987/207150953-d1177cad-da76-40a8-bfdc-4c05f47ce5a0.png)\n\n# About [BlurHash](http://blurha.sh)\n\nBlurHash is a compact representation of a placeholder for an image.\n\nLearn More from the [BlurHash Repo](https://github.com/woltapp/blurhash.git)\n\n### Why would you want this?\n\nDoes your designer cry every time you load their beautifully designed screen, and it is full of empty boxes because all the\nimages have not loaded yet? Does your database engineer cry when you want to solve this by trying to cram little thumbnail\nimages into your data to show as placeholders?\n\nBlurHash will solve your problems! How? Like this:\n\n![WhyBlurHash](https://user-images.githubusercontent.com/30172987/207242393-5446ece1-7d55-412f-92b6-0a7c4cf36860.png)\n\n\nYou can also see nice examples and try it out yourself at [blurha.sh](http://blurha.sh/)!\nLearn More from the [BlurHash Repo](https://github.com/woltapp/blurhash.git)\n\n# Usage\nThere are two ways you can use this package:\n1. Using Async Helpers\n```swift\n// Encoding\nlet blurHashStr = await UnifiedBlurHash.getBlurHashString(from: image)\n\n// Decoding\nlet image = await UnifiedBlurHash.getUnifiedImage(from: imageString)\n\n```\n\n2. Using Methods Directly\n\n```swift\n\n// scale down for performance then encode\nlet blurHashStr = unifiedImage.small?.blurHash(numberOfComponents: (4,4))\n    \n// Decoding. Use small size and resize in UI for performance\nlet image = UnifiedImage(blurHash: blurHashString, size: .init(width: 32, height: 32))\n    \n```\n\n# SwiftUI Examples\n\n```swift \n\nimport SwiftUI\nimport UnifiedBlurHash\n\nstruct ContentView: View {\n    @State private var imageString = \"LVN^Odxa?WNa-;WB£,WBs;baR*af\"\n    @State private var image: UnifiedImage? = nil\n    \n    var body: some View {\n        VStack(spacing: 20) {\n            \n            Button(\"Encode\", action: encode)\n\n            Button(\"Decode\", action: decode)\n\n            if image != nil {\n                Image(unifiedImage: image!)\n                    .resizable()\n            }\n        }\n        .padding(.horizontal)\n    }\n\n    private func encode() {\n        Task {\n            let image = UnifiedImage(named: \"sunflower\")\n            guard let image = image else {\n                return\n            }\n            let str = await UnifiedBlurHash.getBlurHashString(from: image)\n            guard let str = str else {\n                return\n            }\n            DispatchQueue.main.async {\n                self.imageString = str\n            }\n        }\n    }\n\n    private func decode() {\n        Task {\n            let image = await UnifiedBlurHash.getUnifiedImage(from: imageString)\n            guard let image = image else {\n                return\n            }\n            DispatchQueue.main.async {\n                self.image = image\n            }\n        }\n    }\n}\n```\n\nor \n\n```swift \n\nimport SwiftUI\nimport UnifiedBlurHash\n\nstruct ContentView: View {\n    var blurHash: String = \"LVN^Odxa?WNa-;WB£,WBs;baR*af\"\n\n    var body: some View {\n        Image(blurHash: blurHash)?\n            .resizable()\n    }\n}\n\n```\nUnder the hood `UnifiedImage` is just `UIImage` or `NSImage` depending on the platform.\n\n# License\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiankoex%2Funifiedblurhash","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiankoex%2Funifiedblurhash","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiankoex%2Funifiedblurhash/lists"}