package blurhash
All checked builds passInstall
dune-project
Dependency
Authors
Maintainers
Sources
md5=5f9831d3f9a22528f1e28f01ee9aec0b
sha512=d73828e4556c94a2460f05629e69ffee4f481763731cec5cbb87a1dafcedcd337613c39ab67661a08dcc5e15dc3b4ff18b34db3685fe5e245030588aafb75014
Description
A BlurHash encoder in OCaml
README
ocaml-blurhash
A Blurhash encoder implementation written in OCaml.
Usage
The only function provided by ocaml-blurhash is Blurhash.blur_hash_for_pixels, which takes the same arguments as blurHashForPixels in the C reference implementation.
Although ocaml-blurhash does not depend on any image library, you can use camlimages to load an image from a file.
let load_image_as_rgb24 ~path =
match OImages.(load path [] |> tag) with
| Rgb24 img -> img
| Rgba32 img -> img#to_rgb24
| Index8 img -> img#to_rgb24
| Index16 img -> img#to_rgb24
| Cmyk32 _ -> failwith "Not supported image type: Cmyk32"
let blurhash ~x_components ~y_components src =
Blurhash.blur_hash_for_pixels ~x_components ~y_components ~width:src#width
~height:src#height ~bytes_per_row:(src#width * 3) src#dump
let test_encode_case1 () =
let src = load_image_as_rgb24 ~path:"../../../test/test.ppm" in
let hash = blurhash ~x_components:4 ~y_components:3 src in
Alcotest.(check string) "test1" "LFE.@D9F01_2%L%MIVD*9Goe-;WB" hash;
()License
MIT
Dev Dependencies (3)
-
odoc
with-doc -
camlimages
with-test -
alcotest
with-test
Optional Dependencies
None
Used by
None
Conflicts
None
Build status
Results of building blurhash with each compiler on check.ci.ocaml.org, run of against opam-repository 7cdc698. All results for this package.
Each result links to its build log. To keep crawlers from overloading the site, build logs require a GitHub sign-in (see ocurrent/opam-health-check). On your first log, GitHub asks you to “Authorize opam-health-check”, the OCurrent app that runs these checks; it sees only your public profile, not your repositories. The sign-in lasts 30 days.
| Version | OCaml 4.11 | OCaml 4.14 | OCaml 5.2 | OCaml 5.4 | OCaml 5.5 |
|---|---|---|---|---|---|
| 0.1.0 (this version) | good | good | good | good | good |
- good Package successfully built
- partial One of the dependencies failed to build
- bad Package failed to build
- n/a Package is not available in this environment
- internal Internal failure