Expose palette-bit-depth metadata, requires upcoming libvips v8.8.0

This commit is contained in:
Lovell Fuller 2019-01-01 21:01:51 +00:00
parent 30ca424942
commit cc1d4c1a6d
2 changed files with 8 additions and 0 deletions

View File

@ -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<v8::String>(baton->chromaSubsampling).ToLocalChecked());
}
Set(info, New("isProgressive").ToLocalChecked(), New<v8::Boolean>(baton->isProgressive));
if (baton->paletteBitDepth > 0) {
Set(info, New("paletteBitDepth").ToLocalChecked(), New<v8::Uint32>(baton->paletteBitDepth));
}
Set(info, New("hasProfile").ToLocalChecked(), New<v8::Boolean>(baton->hasProfile));
Set(info, New("hasAlpha").ToLocalChecked(), New<v8::Boolean>(baton->hasAlpha));
if (baton->orientation > 0) {

View File

@ -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),