mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Add isPalette and bitsPerSample metadata, deprecate paletteBitDepth
This commit is contained in:
@@ -47,8 +47,11 @@ class MetadataWorker : public Napi::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");
|
||||
if (image.get_typeof(VIPS_META_PALETTE) == G_TYPE_INT) {
|
||||
baton->isPalette = image.get_int(VIPS_META_PALETTE);
|
||||
}
|
||||
if (image.get_typeof(VIPS_META_BITS_PER_SAMPLE) == G_TYPE_INT) {
|
||||
baton->bitsPerSample = image.get_int(VIPS_META_BITS_PER_SAMPLE);
|
||||
}
|
||||
if (image.get_typeof(VIPS_META_N_PAGES) == G_TYPE_INT) {
|
||||
baton->pages = image.get_int(VIPS_META_N_PAGES);
|
||||
@@ -171,8 +174,13 @@ class MetadataWorker : public Napi::AsyncWorker {
|
||||
info.Set("chromaSubsampling", baton->chromaSubsampling);
|
||||
}
|
||||
info.Set("isProgressive", baton->isProgressive);
|
||||
if (baton->paletteBitDepth > 0) {
|
||||
info.Set("paletteBitDepth", baton->paletteBitDepth);
|
||||
info.Set("isPalette", baton->isPalette);
|
||||
if (baton->bitsPerSample > 0) {
|
||||
info.Set("bitsPerSample", baton->bitsPerSample);
|
||||
if (baton->isPalette) {
|
||||
// Deprecated, remove with libvips 8.17.0
|
||||
info.Set("paletteBitDepth", baton->bitsPerSample);
|
||||
}
|
||||
}
|
||||
if (baton->pages > 0) {
|
||||
info.Set("pages", baton->pages);
|
||||
|
||||
@@ -24,7 +24,8 @@ struct MetadataBaton {
|
||||
int density;
|
||||
std::string chromaSubsampling;
|
||||
bool isProgressive;
|
||||
int paletteBitDepth;
|
||||
bool isPalette;
|
||||
int bitsPerSample;
|
||||
int pages;
|
||||
int pageHeight;
|
||||
int loop;
|
||||
@@ -59,7 +60,8 @@ struct MetadataBaton {
|
||||
channels(0),
|
||||
density(0),
|
||||
isProgressive(false),
|
||||
paletteBitDepth(0),
|
||||
isPalette(false),
|
||||
bitsPerSample(0),
|
||||
pages(0),
|
||||
pageHeight(0),
|
||||
loop(-1),
|
||||
|
||||
Reference in New Issue
Block a user