Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/durobot/export_ppm
A couple of functions to export data as a PPM/PGM image file from your Zig code
https://github.com/durobot/export_ppm
pgm pgm-format pgm-image pgm-writer ppm ppm-format ppm-image zig zig-package ziglang
Last synced: about 11 hours ago
JSON representation
A couple of functions to export data as a PPM/PGM image file from your Zig code
- Host: GitHub
- URL: https://github.com/durobot/export_ppm
- Owner: Durobot
- License: mit
- Created: 2023-12-13T14:11:24.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-03-06T11:17:53.000Z (8 months ago)
- Last Synced: 2024-03-06T12:32:54.919Z (8 months ago)
- Topics: pgm, pgm-format, pgm-image, pgm-writer, ppm, ppm-format, ppm-image, zig, zig-package, ziglang
- Language: Zig
- Homepage:
- Size: 18.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# export_ppm
Just a couple of functions in Zig that export image data, RGB/RGBA/grayscale/grayscale+alpha (but alpha channel is ignored), 8 or 16 bits per channel, as PPM/PGM files. Not enough code to be called a library.
PPM and PGM are very simple graphic file formats, but they are widespread enough for popular editors, like [Gimp](https://www.gimp.org/), [Krita](https://krita.org) or [Adobe Photoshop](https://www.adobe.com/creativecloud/file-types/image/raster/ppm-file.html) to be able to open them. Meaning you can quickly dump whatever you want from your Zig programs as a PPM/PGM file and open it in an editor.
See https://en.wikipedia.org/wiki/Netpbm?useskin=vector, https://netpbm.sourceforge.net/doc/ppm.html.
Check out the tests in `export_ppm.zig` for examples of use.
**test_data_src** folder contains PNG images I used as test data, ignore them or use them however you want. I release them in public domain.
**export_ppm.zig** is licensed under [the MIT License](https://en.wikipedia.org/w/index.php?title=MIT_License&useskin=vector).
Just drop `export_ppm.zig` into your project and add `const eppm = @import("export_ppm.zig");`, or use the Zig package manager:
1. In your project's `build.zig.zon`, in `.dependencies`, add
```zig
.export_ppm =
.{
.url = "https://github.com/Durobot/export_ppm/archive/.tar.gz",
.hash = "" // Use arbitrary hash, get correct hash from the error
}
```2. In your project's `build.zig`, in `pub fn build`, before `b.installArtifact(exe);`, add
```zig
const eppm = b.dependency("export_ppm",
.{
.target = target,
.optimize = optimize,
});
exe.root_module.addImport("export_ppm", eppm.module("export_ppm"));
```3. Add `const eppm = @import("export_ppm");`in your source file(s).
4. Build your project with `zig build`, as you normally do.