imageformats 1.0.0

Image formats: JPEG (no encoder), PNG, TGA. One file, no deps.

To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:

Image loading and saving

  • returned image data is always 8-bit (Y/YA/RGB/RGBA)
  • not optimal for 32-bit systems
png8-bit8-bit non-paletted non-interlaced
tga8-bit non-paletted8-bit non-paletted

Let me show you:

import std.stdio;   // File
import imageformats;

void main() {
    // optional last argument defines conversion
    long w, h, chans;
    ubyte[] pixels = read_image("peruna.png", w, h, chans);
    //ubyte[] pixels = read_image("peruna.png", w, h, chans, ColFmt.YA);
    //ubyte[] pixels = read_image("peruna.png", w, h, chans, ColFmt.RGB);

    write_image("peruna.tga", w, h, pixels);
    write_image("peruna.tga", w, h, pixels, ColFmt.RGBA);

    // get basic info without decoding
    read_image_info("peruna.png", w, h, chans);

    // there are also format specific functions
    PNG_Header hdr = read_png_header("peruna.png"); // get detailed info
    ubyte[] idat = read_jpeg("porkkana.jpg", w, h, chans, ColFmt.Y);
    write_tga("porkkana.tga", w, h, idat);
  • Tero Hänninen
7.0.2 2019-Oct-10
7.0.1 2019-Jul-12
7.0.0 2018-Apr-14
6.1.3 2018-Mar-29
6.1.2 2017-Oct-31
Show all 28 versions
Download Stats:
  • 0 downloads today

  • 1 downloads this week

  • 4 downloads this month

  • 53144 downloads total

Short URL: