• Stars
    star
    402
  • Rank 103,646 (Top 3 %)
  • Language
    Zig
  • License
    MIT License
  • Created over 4 years ago
  • Updated 17 days ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Zig library for reading and writing different image formats

Zig Image library

This is a work in progress library to create, process, read and write different image formats with Zig programming language.

License Issue Commit CI

Install & Build

This project assume current Zig master (0.11.0-dev.3879+5804f3f75 or higher) with stage2 self-hosted compiler.

Use zigimg in your project

How to add to your project:

As a submodule

  1. Clone this repository or add as a submodule
  2. Add to your build.zig
exe.addAnonymousModule("zigimg", .{.source_file = .{ .path = "zigimg.zig" }});

Through the package manager

  1. Example build.zig.zon file
.{
    .name = "app",
    .version = "0.0.0",
    .dependencies = .{
        .zigimg = .{
            .url = "https://github.com/zigimg/zigimg/archive/$REPLACE_WITH_WANTED_COMMIT$.tar.gz",
        },
    },
}
  1. When it fails to build due to a mismatched hash, add the hash line to the dependency
.zigimg = .{
    .url = "https://github.com/zigimg/zigimg/archive/$REPLACE_WITH_WANTED_COMMIT$.tar.gz",
    .hash = "$REPLACE_WITH_HASH_FROM_BUILD_ERROR$",
},

Test suite

To run the test suite, checkout the test suite and run

  1. Checkout zigimg
  2. Go back one folder and checkout the test suite
  3. Run the tests with zig build
zig build test

Supported image formats

Image Format Read Write
ANIM ❌ ❌
BMP βœ”οΈ (Partial) ❌
GIF ❌ ❌
ICO ❌ ❌
IILBM ❌ ❌
JPEG ❌ ❌
PAM ❌ ❌
PBM βœ”οΈ ❌
PCX βœ”οΈ ❌
PGM βœ”οΈ (Partial) βœ”οΈ (Partial)
PNG βœ”οΈ βœ”οΈ (Partial)
PPM βœ”οΈ (Partial) ❌
QOI βœ”οΈ βœ”οΈ
TGA βœ”οΈ ❌
TIFF ❌ ❌
XBM ❌ ❌
XPM ❌ ❌

BMP - Bitmap

  • version 4 BMP
  • version 5 BMP
  • 24-bit RGB
  • 32 RGBA
  • Doesn't support any compression

PBM - Portable Bitmap format

  • Everything is supported

PCX - ZSoft Picture Exchange format

  • Support monochrome, 4 color, 16 color and 256 color indexed images
  • Support 24-bit RGB images

PGM - Portable Graymap format

  • Support 8-bit and 16-bit grayscale images
  • 16-bit ascii grayscale loading not tested

PNG - Portable Network Graphics

  • Support all pixel formats supported by PNG (grayscale, grayscale+alpha, indexed, truecolor, truecolor with alpha) in 8-bit or 16-bit.
  • Support the mininal chunks in order to decode the image.
  • Not all images in Png Test Suite is covered but should be good enough for now.

PPM - Portable Pixmap format

  • Support 24-bit RGB (8-bit per channel)
  • Missing 48-bit RGB (16-bit per channel)

QOI - Quite OK Image Format

TGA - Truevision TGA format

  • Supports uncompressed and compressed 8-bit grayscale, indexed with 16-bit colormap, truecolor with 24-bit or 32-bit bit depth.
  • Supports version 1 and version 2