dezoomify-rs icon indicating copy to clipboard operation
dezoomify-rs copied to clipboard

Preserve the image DPI information from individual tiles in the final output

Open Arekkusu1998 opened this issue 5 years ago • 11 comments

All dezoomified maps (small and/or large) are at 96 dpi, although some are reported as 300 dpi. I did a test with this small-sized map from BNF Gallica, dezoomifying it first directly (obtaining an image at 300 dpi), then with dezoomify (obtaining an image at 96 dpi)😯. Same for other maps, not only from BNF. This is even more true of dezoomify-rs: the large cadastral maps of Venice and Milan State Archives were uploaded at 300 dpi (archival authority confirms this fact), but are dezoomified at 96 dpi. Why? Are the two softwares calibrated exclusively at 96 dpi? If so, is there a way to get the image at 300 dpi🤔?

Warning: I underline that the images to which I refer are really very large, so Photopea and Photoshop Portable freeze if I try to (re)convert them to 300 dpi.

Arekkusu1998 avatar Nov 21 '19 11:11 Arekkusu1998

Hello, The library we use to save jpeg images does not allow setting exif metadata (including DPI) on the image. Please note that the DPI is purely a meta-information, and has nothing to do with the actual quality of the image. If you really want to set the DPI (I'd be curious to know what your use-case is), you can do it with, for instance, exiftool:

exiftool -XResolution=300 -YResolution=300 -ResolutionUnit=inches -overwrite_original your_image.jpg

A more interesting feature would be to allow the user to specify the quality parameter that is passed to the JPEG encoder for the final image creation (this feature was recently added to gapdecoder). If you are interested in that, feel free to open another issue.

lovasoa avatar Nov 21 '19 13:11 lovasoa

If your request was indeed about DPI meta-information that is lost during dezooming and not image quality, then you can re-open this issue.

lovasoa avatar Nov 21 '19 13:11 lovasoa

Thank You very much, @Lovasoa for Your promptness and for having kindly reported me about ExifTool and the system to recalibrate the parameters ...

exiftool -XResolution=300 -YResolution=300 -ResolutionUnit=inches -overwrite_original your_image.jpg

... although in substance it took almost half a day 🙄 to understand how it worked both for a single image and for a whole folder, now I know how to correct the DPI problem. Anyway, I know that DPI is a meta-info and has nothing to do with images' quality.

You also write:

If your request was indeed about DPI meta-information that is lost during dezooming and not image quality, then you can re-open this issue.

I don't know whether to do it or not: what I regret is that the original DPI.

Arekkusu1998 avatar Nov 22 '19 10:11 Arekkusu1998

What exactly do you need the dpi information for ?

lovasoa avatar Nov 22 '19 17:11 lovasoa

The people I work with are meticulous: if maps are available at 300 dpi, they prefer that; and, since Milan & Venice State Archives have upload them at 300 dpi, I wanted to rectify this metadata.

Arekkusu1998 avatar Nov 23 '19 12:11 Arekkusu1998

Ok, I'm reopening this, then !

Currently, the libraries we use do not have support for custom DPIs, but that's changing :

  • I proposed a change to allow writing density information and it got accepted in https://github.com/image-rs/image/pull/1078
  • Someone proposed a similar change for reading density information in https://github.com/image-rs/jpeg-decoder/pull/115

lovasoa avatar Nov 24 '19 14:11 lovasoa

I'm glad to have aroused so much interest in the GitHub community, @lovasoa. But I was wondering: since I understand very little about computer science, in the light of the threads mentioned by You above, how will dezoomify-rs change🤔? You've write that the idea to allow writing density information was accepted in image-rs/image#1078.

Arekkusu1998 avatar Nov 26 '19 12:11 Arekkusu1998

dezoomify-rs uses what is called a software library to read and write JPEG files. The code of this library is not specific to dezoomify-rs, but is shared with many other projects. Once a new version of the library is released, and adds functions to read and write pixel density information, we will be able to use these functions to implement the functionality you wanted in dezoomify-rs. This may take a long time.

lovasoa avatar Nov 26 '19 13:11 lovasoa

Okay, that's fine @lovasoa: in the meantime that You experts 🧐 work on the software library, I'll use exiftool, as kindly indicated from You. Thanks and good work to everyone!

Arekkusu1998 avatar Nov 26 '19 16:11 Arekkusu1998

Any update on this? :)

Boscop avatar Nov 16 '20 06:11 Boscop

The image library that we use, image-rs does not have any generic support for meta-information on image files. It can write DPI information (on jpeg files only), but not read it.

@Boscop: If you want to add support for this, the work starts in these external libraries: image-rs, jpeg-decoder, and other image format libraries if we want to support this feature for them too.

lovasoa avatar Nov 16 '20 10:11 lovasoa