Provide XMP as a string, as well as a Buffer, where possible

This commit is contained in:
Lovell Fuller
2025-07-04 15:55:41 +01:00
parent 4e3f3792ad
commit 8ee8d273ee
5 changed files with 12 additions and 0 deletions

View File

@@ -262,6 +262,10 @@ class MetadataWorker : public Napi::AsyncWorker {
}
if (baton->xmpLength > 0) {
info.Set("xmp", Napi::Buffer<char>::NewOrCopy(env, baton->xmp, baton->xmpLength, sharp::FreeCallback));
if (g_utf8_validate(static_cast<char const *>(baton->xmp), baton->xmpLength, nullptr)) {
info.Set("xmpAsString",
Napi::String::New(env, static_cast<char const *>(baton->xmp), baton->xmpLength));
}
}
if (baton->tifftagPhotoshopLength > 0) {
info.Set("tifftagPhotoshop",