emcconville / wand

The ctypes-based simple ImageMagick binding for Python
http://docs.wand-py.org/
Other
1.42k stars 199 forks source link

Tiff file created by Wand does not have HorizontalPixelSize metadata #650

Closed hep-canoy closed 9 months ago

hep-canoy commented 9 months ago

I am using Wand on my microservice called File Converter. On pdf to tiff converter, the tiff created does not contain HorizontalPixelSize (and other metadata) which is needed by another application which is a tiff viewer.

Upon checking the metadata when converting tiff to tiff (adjusting dpi) these are the metadata present

  1. PixelAspectRatio
  2. ImageOrientation
  3. HorizontalPixelSize
  4. VerticalPixelSize
  5. HorizontalPosition
  6. VerticalPosition

When doing pdf to tiff, these are the only metadata present

  1. PixelAspectRatio
  2. ImageOrientation

We need HorizontalPixelSize metadata since we store the resolution of the tiff file in our database.

I am just curious why tiff derived from pdf lacks these important metadata.

emcconville commented 9 months ago

I am just curious why tiff derived from pdf lacks these important metadata.

Can't really offer much help without evaluating source files, but I would guess this behavior comes down to the nuances of tagging. Possible some EXIF data needs to be re-keyed as TIFF standard tagging. See this chart.

https://docs.oracle.com/en/java/javase/21/docs//api/java.desktop/javax/imageio/metadata/doc-files/tiff_metadata.html#MapStandardNative

However Wand & ImageMagick doesn't really edit metatags. You can use Image.profile to dump & load raw data streams. A possible solution might be as simple as reading a PDF, export EXIF / XMP, modify payload, import EXIF / XMP, and write file.

hep-canoy commented 9 months ago

Just to give an update, it's the problem with metadata format mapping, not with wand. The Standard Metadata Format does not able to detect the metadata we need which is the HorizontalReoslution, in which we solved it by adding another layer to that that will use TIFF Native Image Metadata Format if it cannot find the metadata using the Standard Metadata Format.