Skip to content

Make images smaller using best-in-class codecs, right in the browser.

JavaScript

Use bt709 if not lossless so colour is correct

Jake Archibald549e1fc50a62
diff --git a/codecs/avif/enc/avif_enc.cpp b/codecs/avif/enc/avif_enc.cpp
index d8d13b8b..e13e4b2d 100644
--- a/codecs/avif/enc/avif_enc.cpp
+++ b/codecs/avif/enc/avif_enc.cpp
@@ -58,6 +58,8 @@ val encode(std::string buffer, int width, int height, AvifOptions options) {
format == AVIF_PIXEL_FORMAT_YUV444
) {
image->matrixCoefficients = AVIF_MATRIX_COEFFICIENTS_IDENTITY;
+ } else {
+ image->matrixCoefficients = AVIF_MATRIX_COEFFICIENTS_BT709;
}
uint8_t* rgba = (uint8_t*)buffer.c_str();
diff --git a/codecs/avif/enc/avif_enc.wasm b/codecs/avif/enc/avif_enc.wasm
index 48c0c2ac..bfd868d7 100644
Binary files a/codecs/avif/enc/avif_enc.wasm and b/codecs/avif/enc/avif_enc.wasm differ