/blurhash-scala

Scala implementation of blurhash

Primary LanguageScalaApache License 2.0Apache-2.0

blurhash-scala

Scala implementation of blurhash

Usage

build.sbt

resolvers += Resolver.bintrayRepo("mrks", "maven")
libraryDependencies += "mrks" %% "blurhash-scala" % "1.0.0"

Example.scala

import javax.imageio.ImageIO
import java.io.File

import mrks.blurhash.Blurhash

object Example {
  def encode(file: File): String = {
    val image = ImageIO.read(file)
    Blurhash.encode(image, 4, 3)
  }

  def decode(blurhash: String): Either[Blurhash.Error, File] = {
    Blurhash.decode(blurhash, 40, 30).map { image =>
      ImageIO.write(image, "PNG", new File("target.png"))
    }
  }
}