dlemstra / Magick.NET

The .NET library for ImageMagick
Apache License 2.0
3.48k stars 415 forks source link

How to set Tif Tag PHOTOMETRIC form BlackIsZero to WhiteIsZero ? #1757

Open Charltsing opened 1 day ago

Charltsing commented 1 day ago

Magick.NET version

13.10.0

Environment (Operating system, version and so on)

Windows10, net framework 4.7.2

Description

I save pbm to tif, Tif Tag PHOTOMETRIC is BlackIsZero. I want to change BlackIsZero to WhiteIsZero to align with the behavior of other software

BlackIsZero

BlackIsZero.zip

using (ImageMagick.MagickImage processed = new ImageMagick.MagickImage(pnmBytes))
{
    processed.Format = ImageMagick.MagickFormat.Tif;

    processed.Settings.Depth = 1;
    processed.Settings.ColorSpace = ImageMagick.ColorSpace.Gray;
    processed.Settings.ColorType = ImageMagick.ColorType.Bilevel;
    processed.Settings.Compression = ImageMagick.CompressionMethod.Group4;

    // How to set  Tif Tag PHOTOMETRIC to WiiteIsZero

    processed.Write(outstream, ImageMagick.MagickFormat.Tif);
}
dlemstra commented 10 hours ago

What happens when you add this:

processed.Settings.SetDefine(MagickFormat.Tiff, "quantum:polarity", "min-is-white");

This should probably be added to the TiffWriteDefines.