sharp icon indicating copy to clipboard operation
sharp copied to clipboard

HOWTO set Photometric Interpretation to min-is-white

Open geabenitez opened this issue 4 years ago • 4 comments

I am using this piece of code await sharp(./${file}.tif) .toColourspace('b-w') .tiff({ compression: 'ccittfax4', xres: size, yres: size, bitdepth: 1 }) .toFile(output_${dpi}.tif)

but I am getting Photometric Interpretation: min-is-black and I need it to be min-is-white

Any suggestion on how I can achieve the min-is-white?

geabenitez avatar Apr 11 '22 15:04 geabenitez

Another term for this is Quantum Polarity. I too am interested in figuring out how to set this using this library.

In ImageMagick we can just do convert source.tif -define tiff:quantum:polarity=min-is-white dest.tif but that requires a dependency that I'd rather not have to install on server instances.

dcbartlett avatar Apr 12 '22 16:04 dcbartlett

To support this we'll need to expose libvips' miniswhite setting as a property on tiff()

https://sharp.pixelplumbing.com/api-output#tiff

https://www.libvips.org/API/current/VipsForeignSave.html#vips-tiffsave

Happy to accept a PR, if you're able.

lovell avatar Apr 16 '22 10:04 lovell

To support this we'll need to expose libvips' miniswhite setting as a property on tiff()

https://sharp.pixelplumbing.com/api-output#tiff

https://www.libvips.org/API/current/VipsForeignSave.html#vips-tiffsave

Happy to accept a PR, if you're able.

Hey @lovell, I haven't worked on a project like this before, where should I be able find guidance so I can work on the PR? Tx.

geabenitez avatar Apr 21 '22 20:04 geabenitez

@geabenitez Thank you for offering to take a look. Perhaps you could adopt a code path like that used with the existing pyramid boolean option of tiff(), as I would imagine adding miniswhite will be very similar.

https://github.com/lovell/sharp/blob/5b03579e5c29dc38e90b0c2bb685411ff89b570e/lib/output.js#L753-L755

https://github.com/lovell/sharp/search?q=tiffPyramid

lovell avatar Apr 25 '22 13:04 lovell

v0.33.0 is now available with .tiff({ miniswhite: true }) property - see https://sharp.pixelplumbing.com/api-output#tiff

lovell avatar Nov 29 '23 13:11 lovell