0

I am trying to replace libtiff into WIC (since libtiff is not able to pass Black Duck Analysis tool anymore)

I have used their example https://learn.microsoft.com/en-us/windows/win32/wic/-wic-creating-encoder

And I was able to create a tiff. I also needed to change the compression type so I change the code into

    if (SUCCEEDED(hr))
        {
            // This is how you customize the TIFF output.
            PROPBAG2 option = { 0 };
            option.pstrName = L"TiffCompressionMethod";
            VARIANT varValue;
            VariantInit(&varValue);
            varValue.vt = VT_UI1;
            varValue.bVal = WICTiffCompressionRLE;
            hr = pPropertybag->Write(1, &option, &varValue);
            if (SUCCEEDED(hr))
            {
                hr = piBitmapFrame->Initialize(pPropertybag);
            }
}

My new image has Resolution Unit 2 and I would like to set it into 1 enter image description here

I found out this https://learn.microsoft.com/en-us/windows/win32/wic/-wic-photoprop-system-image-resolutionunit but I do not understand how to use the WIC metadata API in order to change this.

Can you help?

Gilad
  • 6,437
  • 14
  • 61
  • 119
  • 1
    Writing metadata is explained here: https://learn.microsoft.com/en-us/windows/win32/wic/-wic-codec-readingwritingmetadata#obtaining-a-query-writer but I don't think you can change Resolution Unit with WIC as (from experience and logic https://photo.stackexchange.com/questions/96896/what-is-a-resolution-unit) this is overridden by the encoder. But you can change other metadata for example image id: https://learn.microsoft.com/en-us/windows/win32/wic/-wic-photoprop-system-image-imageid – Simon Mourier Apr 17 '22 at 10:38

1 Answers1

1

The WIC built-in TIFF encoder always writes the TIFFTAG_RESOLUTIONUNIT as 2 (inches). You can use WIC to read the existing tag, but you can't write a different value for this particular metadata item.

Chuck Walbourn
  • 38,259
  • 2
  • 58
  • 81