Coder Social home page Coder Social logo

blurhash-zig's Introduction

blurhash-zig

Implementation of BlurHash algorithm in Zig. For now it only supports encoding an image as a Hash

The Nim implementation of BlurHash was used heavliy as a reference for this code

I also used Zig Image Library (aka zigimg) and Zig String as dependencies to make my life a lot easier. Dependency management is handled with the unofficial package manager gyro

Usage

This code targets Zig 0.9.1 which is the latest stable release as of the code being written, so ensure that is installed before trying to run this.

This also uses gyro to handle dependencies. As this code uses Zig 0.9.1, and the current release of gyro seemst to expect a build from the current master branch (higher than 0.10.0-dev), you need to install a compatible version of gyro. 0.4.1 worked for me

The dependency libraries are pinned to versions which work with Zig 0.9.1

Running on the command line

gyro build run -- /path/to/image

Using as a library

Init your gyro project and add this repo as a dependency. Ensure your build.zig uses the gyro generated deps.zig. You can check the build.zig from this repo as a reference to see what that might look like

gyro init
gyro add --src github mhoward540/blurhash-zig

Then import it in your code:

const blurhash = @import("blurhash");

You need to pass an instance of a zigimg.Image to the blurhash encode function right now, so you'll probably need zigimg as a dependency for your own code as well

Running tests

gyro build test

Image format support

It can read all file formats supported by zigimg, though I've only tested and confirmed PNG and QOI images as working. This implmentation does not handle Alpha values / transparency, so it will return an error when encountering an image which has any transparency.

blurhash-zig's People

Contributors

alexkuz avatar mhoward540 avatar

Watchers

 avatar

Forkers

alexkuz

blurhash-zig's Issues

Concider replacing zigimg with C image library

zigimg library is very much work in progress and doesn't support a lot of image formats.
I suggest replacing it with some mature library like https://github.com/nothings/stb
It also could have performance benefits - I have a suspicion zigimg is not optimal with big images.

(I tried to implement this myself, but my knowledge of C/Zig ecosystem is superficial and I failed to make the linker happy)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.