-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set DPI #54
Set DPI #54
Conversation
I added the fix in |
Oh, @kba, am I supposed to use |
@bertsky We should choose a definite option for accessing image information in the long run. This could be either |
After a little research, I think that the image resolution is stored in JFIF meta data section which both $ exiftool IMG/FILE_0033_ORIGINAL.jpg
ExifTool Version Number : 10.80
File Name : FILE_0033_ORIGINAL.jpg
Directory : IMG
File Size : 329 kB
File Modification Date/Time : 2019:07:04 17:07:41+02:00
File Access Date/Time : 2019:07:09 14:40:50+02:00
File Inode Change Date/Time : 2019:07:04 17:07:46+02:00
File Permissions : rw-r--r--
File Type : JPEG
File Type Extension : jpg
MIME Type : image/jpeg
JFIF Version : 1.01
Resolution Unit : inches
X Resolution : 300
Y Resolution : 300
Image Width : 1187
Image Height : 1687
Encoding Process : Baseline DCT, Huffman coding
Bits Per Sample : 8
Color Components : 3
Y Cb Cr Sub Sampling : YCbCr4:2:0 (2 2)
Image Size : 1187x1687
Megapixels : 2.0 vs. >>> from PIL import Image
>>> Image.open("IMG/FILE_0033_ORIGINAL.jpg")
<PIL.JpegImagePlugin.JpegImageFile image mode=RGB size=1187x1687 at 0x7F7958245C18>
>>> img = Image.open("IMG/FILE_0033_ORIGINAL.jpg")
>>> img.info
{'jfif': 257, 'jfif_version': (1, 1), 'dpi': (300, 300), 'jfif_unit': 1, 'jfif_density': (300, 300)} |
That's right, but there are more options than JPG here. And it can always be empty. And core's |
This is the recommended way, though not as stable as I'd wish. The variability of image metadata is immense and The
True, that should be made explicit. We have some information at https://ocr-d.github.io/gt//trans_documentation/exif_pagexml_konkordanz.html from early 2018 when we considered encoding image metadata with MIX. |
But on the other hand, how should this possibly be related to the spec? We cannot teach the implementors how to talk to their underlying processors (in how they should determine and pass down DPI values). We can only make the annotation in PAGE mandatory (i.e. Then we would of course generously provide a specialized processor that just annotates that (using |
We had long discussions on this last year and decided to use the image itself as the single source of truth for all technical image metadata. Duplicating the information from the image in PAGE could lead to metadata drift (e.g. the image changes but the PAGE doesn't reflect that or the annotations are missing in PAGE) whereas the image is always available. In addition, the 2017 PAGE version didn't have the attributes yet. How this is related to the spec: Different image file formats support different metadata schemes, like EXIF, JFIF or PNG tags. While an abstraction like Originally, the plan was to have an image characterization step that does all the metadata extraction, like you propose, and refuse processing bad images if pixel density too low etc. In reality, it is next to impossible to guess pixel density and the image metadata often cannot be trusted. That being said, I'm open to encoding this in PAGE instead if that makes life easier for developers and users. This would require a dedicated processor as the first step in any pipeline though, since the input file group will be images. |
Related: OCR-D/core#37 (re-open there?) |
…t annotation in case AlternativeImage was already present)
No description provided.