Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vanniktech/blurhash
BlurHash support for iOS, Android and JVM via Kotlin Multiplatform
https://github.com/vanniktech/blurhash
android backend ios jvm kotlin kotlin-multiplatform
Last synced: 2 months ago
JSON representation
BlurHash support for iOS, Android and JVM via Kotlin Multiplatform
- Host: GitHub
- URL: https://github.com/vanniktech/blurhash
- Owner: vanniktech
- License: mit
- Created: 2022-09-09T09:55:02.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-05-21T12:38:17.000Z (8 months ago)
- Last Synced: 2024-05-22T12:35:35.095Z (8 months ago)
- Topics: android, backend, ios, jvm, kotlin, kotlin-multiplatform
- Language: Kotlin
- Homepage:
- Size: 2.08 MB
- Stars: 39
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/funding.yml
- License: LICENSE
Awesome Lists containing this project
- mobile-awesome - blurhash - BlurHash support for iOS, Android and JVM via Kotlin Multiplatform. (Multiplatform / Android samples)
README
blurhash
========A Kotlin Multiplatform library to use [blurhash](https://blurha.sh/) in your Android App, iOS / Mac App & JVM Backend.
| `Android` | `iOS` | `JVM` |
|:--------------------------------------|:------------------------------|:------------------------------|
| ![Sample Android](sample-android.png) | ![Sample iOS](sample-ios.png) | ![Sample JVM](sample-jvm.png) |# Why?
If you've tried using [blurhash](https://blurha.sh/), you qickly stumple upon the [main repository](https://github.com/woltapp/blurhash). They provide sources for [Swift](https://github.com/woltapp/blurhash/tree/master/Swift), [Typescript](https://github.com/woltapp/blurhash/tree/master/TypeScript), [Python](https://github.com/woltapp/blurhash-python), [Kotlin](https://github.com/woltapp/blurhash/tree/master/Kotlin) and [C](https://github.com/woltapp/blurhash/tree/master/C). However:
- Implementations produce [different hashes for the same picture](https://github.com/woltapp/blurhash/issues/196)
- There are no artifacts to consume i.e. no Cocoa Pod or Maven dependency
- Not all implementations provide both encoding and decoding support
- Missing sample apps with consistent images and blur hashesThe goal of this library is to solve all of the above mentioned problems, provide a common API and good samples for each platform.
# Usage
From Kotlin Multiplatform:
```groovy
kotlin {
sourceSets {
val commonMain by getting {
dependencies {
implementation("com.vanniktech:blurhash:0.4.0-SNAPSHOT")
}
}
}
}
```From Android / JVM Multiplatform:
```groovy
dependencies {
implementation("com.vanniktech:blurhash:0.4.0-SNAPSHOT")
}
```From iOS:
```ruby
pod 'BlurHash', :git => 'https://github.com/vanniktech/blurhash', :tag => "0.4.0-SNAPSHOT"
```# API
Use `com.vanniktech.blurhash.BlurHash` directly in your platform specific code to `encode` as well as `decode`:
- [sample-android](./sample-android/src/main/kotlin/com/vanniktech/blurhash/sample/android/BlurHashMainActivity.kt): Works with `Bitmap`
- [sample-ios](./sample-ios/ios/App.swift): Works with `UIImage` (Use `import blurhash` & `BlurHash.shared`)
- [sample-jvm](sample-jvm/src/main/java/com/vanniktech/blurhash/sample/jvm/BlurHashJvm.kt): Works with `BufferedImage`# Thanks
Without them this would not exist!
- [woltapp](https://github.com/woltapp) for creating [blurbash](https://github.com/woltapp/blurhash)
- [Hendrik Schnepel](https://github.com/hsch) for the [encoding implementation](https://github.com/hsch/blurhash-java)# License
Copyright (C) 2022 - Niklas Baudy
Licensed under the MIT License