Impute TIFF xres/yres from withMetadata({density})#2952
Impute TIFF xres/yres from withMetadata({density})#2952mbklein wants to merge 1 commit intolovell:masterfrom
Conversation
|
@lovell While creating two new tests for this functionality, I discovered that I couldn't get them to fail at all when written as promises. I believe this is due to the fact that the |
|
Hi Michael, thank you very much for this PR, and always a pleasure to see unit tests too. I wonder if it might be a little simpler to have this logic in the C++ layer, perhaps something like the following: --- a/src/pipeline.cc
+++ b/src/pipeline.cc
@@ -1496,6 +1496,9 @@ Napi::Value pipeline(const Napi::CallbackInfo& info) {
baton->tiffTileHeight = sharp::AttrAsUint32(options, "tiffTileHeight");
baton->tiffXres = sharp::AttrAsDouble(options, "tiffXres");
baton->tiffYres = sharp::AttrAsDouble(options, "tiffYres");
+ if (baton->tiffXres == 1.0 && baton->tiffYres == 1.0 && baton->withMetadataDensity > 0) {
+ baton->tiffXres = baton->tiffYres = baton->withMetadataDensity / 25.4;
+ }
// tiff compression options
baton->tiffCompression = static_cast<VipsForeignTiffCompression>(
vips_enum_from_nick(nullptr, VIPS_TYPE_FOREIGN_TIFF_COMPRESSION,I think this should still satisfy the test cases you added. |
|
I skimmed |
|
Brilliant, thank you, landed via commit 342de36 |
Closes #2941
This PR uses the
densityvalue passed towithMetadata()as a fallback if the output format is TIFF and netterxresnoryresis provided in the TIFF options. I've also updated the API documentation with to include a short explanation of this behavior.