Skip to content
This repository has been archived by the owner on Jun 15, 2020. It is now read-only.

georgy7/dlib-webp

Repository files navigation

Dub version Build Status Coverage Status

Testing

dub test --debug=featureTest

Usage

import dlib.image;
import dlibwebp;

void main() {
  auto img = loadPNG("input.png");

  // Medium quality.
  img.saveWEBP("quality.webp");

  img.saveWEBP("q50.webp", 50);

  img.saveWEBP("hq.webp", WEBPQuality.HIGH);

  // But it is still YUV 4:2:0.
  img.saveWEBP("q100.webp", WEBPQuality.HIGHEST);

  // And it is not.
  img.saveWEBP("lossless.webp", WEBPQuality.LOSSLESS);

  // You may want to use the streaming API
  // just like savePNG, saveTGA, etc.
  // auto res = img.saveWEBP(outputStream, 50);

  // Also, you can save to arrays:
  // ubyte[] lossy = img.saveWEBPToArray();
  // ubyte[] lossy50 = img.saveWEBPToArray(50);
  // ubyte[] lossless = img.saveWEBPToArray(WEBPQuality.LOSSLESS);

  // And back.
  auto readBack = loadWEBP("lossless.webp");
  readBack.savePNG("lossless.png");

  // Also available:
  // loadWEBP(inputStream)
  // loadWEBP(ubyte[])
}

License

Boost Software License, Version 1.0 http://www.boost.org/LICENSE_1_0.txt

Dependencies: