mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Expose raw TIFFTAG_PHOTOSHOP metadata #1600
This commit is contained in:
@@ -116,6 +116,14 @@ class MetadataWorker : public Nan::AsyncWorker {
|
||||
memcpy(baton->xmp, xmp, xmpLength);
|
||||
baton->xmpLength = xmpLength;
|
||||
}
|
||||
// TIFFTAG_PHOTOSHOP
|
||||
if (image.get_typeof(VIPS_META_PHOTOSHOP_NAME) == VIPS_TYPE_BLOB) {
|
||||
size_t tifftagPhotoshopLength;
|
||||
void const *tifftagPhotoshop = image.get_blob(VIPS_META_PHOTOSHOP_NAME, &tifftagPhotoshopLength);
|
||||
baton->tifftagPhotoshop = static_cast<char *>(g_malloc(tifftagPhotoshopLength));
|
||||
memcpy(baton->tifftagPhotoshop, tifftagPhotoshop, tifftagPhotoshopLength);
|
||||
baton->tifftagPhotoshopLength = tifftagPhotoshopLength;
|
||||
}
|
||||
}
|
||||
|
||||
// Clean up
|
||||
@@ -189,6 +197,12 @@ class MetadataWorker : public Nan::AsyncWorker {
|
||||
New("xmp").ToLocalChecked(),
|
||||
Nan::NewBuffer(baton->xmp, baton->xmpLength, sharp::FreeCallback, nullptr).ToLocalChecked());
|
||||
}
|
||||
if (baton->tifftagPhotoshopLength > 0) {
|
||||
Set(info,
|
||||
New("tifftagPhotoshop").ToLocalChecked(),
|
||||
Nan::NewBuffer(baton->tifftagPhotoshop, baton->tifftagPhotoshopLength, sharp::FreeCallback, nullptr)
|
||||
.ToLocalChecked());
|
||||
}
|
||||
argv[1] = info;
|
||||
}
|
||||
|
||||
|
||||
@@ -48,6 +48,8 @@ struct MetadataBaton {
|
||||
size_t iptcLength;
|
||||
char *xmp;
|
||||
size_t xmpLength;
|
||||
char *tifftagPhotoshop;
|
||||
size_t tifftagPhotoshopLength;
|
||||
std::string err;
|
||||
|
||||
MetadataBaton():
|
||||
@@ -71,7 +73,9 @@ struct MetadataBaton {
|
||||
iptc(nullptr),
|
||||
iptcLength(0),
|
||||
xmp(nullptr),
|
||||
xmpLength(0) {}
|
||||
xmpLength(0),
|
||||
tifftagPhotoshop(nullptr),
|
||||
tifftagPhotoshopLength(0) {}
|
||||
};
|
||||
|
||||
NAN_METHOD(metadata);
|
||||
|
||||
Reference in New Issue
Block a user