Does your designer cry every time you load their beautifully designed screen, and it is full of empty boxes because all the
images have not loaded yet? Does your database engineer cry when you want to solve this by trying to cram little thumbnail
images into your data to show as placeholders?
BlurHash will solve your problems! How? Like this:
You can also see nice examples and try it out yourself at blurha.sh!
Learn More from the BlurHash Repo
Usage
There are two ways you can use this package:
Using Async Helpers
```swift
// Encoding
let blurHashStr = await UnifiedBlurHash.getBlurHashString(from: image)
// Decoding
let image = await UnifiedBlurHash.getUnifiedImage(from: imageString)
2. Using Methods Directly
```swift
// scale down for performance then encode
let blurHashStr = unifiedImage.small?.blurHash(numberOfComponents: (4,4))
// Decoding. Use small size and resize in UI for performance
let image = UnifiedImage(blurHash: blurHashString, size: .init(width: 32, height: 32))
UnifiedBlurHash
Extensions of
UIImage
andNSImage
to encode and decode blur hashes, based on Wolt’s Implementation for Swift (iOS).Based on Mortenjust’s Implementation for macOS
Screenshot
About BlurHash
BlurHash is a compact representation of a placeholder for an image.
Learn More from the BlurHash Repo
Why would you want this?
Does your designer cry every time you load their beautifully designed screen, and it is full of empty boxes because all the images have not loaded yet? Does your database engineer cry when you want to solve this by trying to cram little thumbnail images into your data to show as placeholders?
BlurHash will solve your problems! How? Like this:
You can also see nice examples and try it out yourself at blurha.sh! Learn More from the BlurHash Repo
Usage
There are two ways you can use this package:
// Decoding let image = await UnifiedBlurHash.getUnifiedImage(from: imageString)
SwiftUI Examples
or
Under the hood
UnifiedImage
is justUIImage
orNSImage
depending on the platform.License
Run Wild