mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Add chromaSubsampling and isProgressive to metadata #1186
This commit is contained in:
@@ -62,6 +62,12 @@ class MetadataWorker : public Nan::AsyncWorker {
|
||||
if (sharp::HasDensity(image)) {
|
||||
baton->density = sharp::GetDensity(image);
|
||||
}
|
||||
if (image.get_typeof("jpeg-chroma-subsample") == VIPS_TYPE_REF_STRING) {
|
||||
baton->chromaSubsampling = image.get_string("jpeg-chroma-subsample");
|
||||
}
|
||||
if (image.get_typeof("interlaced") == G_TYPE_INT) {
|
||||
baton->isProgressive = image.get_int("interlaced") == 1;
|
||||
}
|
||||
baton->hasProfile = sharp::HasProfile(image);
|
||||
// Derived attributes
|
||||
baton->hasAlpha = sharp::HasAlpha(image);
|
||||
@@ -125,6 +131,12 @@ class MetadataWorker : public Nan::AsyncWorker {
|
||||
if (baton->density > 0) {
|
||||
Set(info, New("density").ToLocalChecked(), New<v8::Uint32>(baton->density));
|
||||
}
|
||||
if (!baton->chromaSubsampling.empty()) {
|
||||
Set(info,
|
||||
New("chromaSubsampling").ToLocalChecked(),
|
||||
New<v8::String>(baton->chromaSubsampling).ToLocalChecked());
|
||||
}
|
||||
Set(info, New("isProgressive").ToLocalChecked(), New<v8::Boolean>(baton->isProgressive));
|
||||
Set(info, New("hasProfile").ToLocalChecked(), New<v8::Boolean>(baton->hasProfile));
|
||||
Set(info, New("hasAlpha").ToLocalChecked(), New<v8::Boolean>(baton->hasAlpha));
|
||||
if (baton->orientation > 0) {
|
||||
|
||||
@@ -31,6 +31,8 @@ struct MetadataBaton {
|
||||
int channels;
|
||||
std::string depth;
|
||||
int density;
|
||||
std::string chromaSubsampling;
|
||||
bool isProgressive;
|
||||
bool hasProfile;
|
||||
bool hasAlpha;
|
||||
int orientation;
|
||||
@@ -50,6 +52,7 @@ struct MetadataBaton {
|
||||
height(0),
|
||||
channels(0),
|
||||
density(0),
|
||||
isProgressive(false),
|
||||
hasProfile(false),
|
||||
hasAlpha(false),
|
||||
orientation(0),
|
||||
|
||||
Reference in New Issue
Block a user