From cc1d4c1a6d7521e366f4b948262e5687df8ad93e Mon Sep 17 00:00:00 2001 From: Lovell Fuller Date: Tue, 1 Jan 2019 21:01:51 +0000 Subject: [PATCH] Expose palette-bit-depth metadata, requires upcoming libvips v8.8.0 --- src/metadata.cc | 6 ++++++ src/metadata.h | 2 ++ 2 files changed, 8 insertions(+) diff --git a/src/metadata.cc b/src/metadata.cc index 394209f2..efd91214 100644 --- a/src/metadata.cc +++ b/src/metadata.cc @@ -68,6 +68,9 @@ class MetadataWorker : public Nan::AsyncWorker { if (image.get_typeof("interlaced") == G_TYPE_INT) { baton->isProgressive = image.get_int("interlaced") == 1; } + if (image.get_typeof("palette-bit-depth") == G_TYPE_INT) { + baton->paletteBitDepth = image.get_int("palette-bit-depth"); + } baton->hasProfile = sharp::HasProfile(image); // Derived attributes baton->hasAlpha = sharp::HasAlpha(image); @@ -140,6 +143,9 @@ class MetadataWorker : public Nan::AsyncWorker { New(baton->chromaSubsampling).ToLocalChecked()); } Set(info, New("isProgressive").ToLocalChecked(), New(baton->isProgressive)); + if (baton->paletteBitDepth > 0) { + Set(info, New("paletteBitDepth").ToLocalChecked(), New(baton->paletteBitDepth)); + } Set(info, New("hasProfile").ToLocalChecked(), New(baton->hasProfile)); Set(info, New("hasAlpha").ToLocalChecked(), New(baton->hasAlpha)); if (baton->orientation > 0) { diff --git a/src/metadata.h b/src/metadata.h index 6907b182..d279e433 100644 --- a/src/metadata.h +++ b/src/metadata.h @@ -33,6 +33,7 @@ struct MetadataBaton { int density; std::string chromaSubsampling; bool isProgressive; + int paletteBitDepth; bool hasProfile; bool hasAlpha; int orientation; @@ -53,6 +54,7 @@ struct MetadataBaton { channels(0), density(0), isProgressive(false), + paletteBitDepth(0), hasProfile(false), hasAlpha(false), orientation(0),