Can't read metadata data (EXIF) information in JPEG files #84661

Closed
opened 2021-01-13 05:45:54 +01:00 by Charles Semeon · 17 comments

System Information
Operating system: Windows-10-10.0.19041-SP0 64 Bits
Graphics card: GeForce RTX 2070 SUPER/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 451.67

Blender Version
Broken: version: 2.91.0, branch: master, commit date: 2020-11-25 08:34, hash: 0f45cab862
Worked: (newest version of Blender that worked as expected)

Short description of error
A bit of context first, I setup a Node group that helps me scale textures to real world scale. So I use the images DPI or PPM for this. Thus I scripted the inputs for the Node groups to automatically grab the relevant information.

It works fine with PNG and TIF but not with JPEG. I use the script below to gather the DPI. For JPEGs, I get the wrong DPI, 72 dpi (2834.646 ppm). Even if the correct value should be higher, blender always displays 72dpi.

To overcome this, I added a python module ExifRead. There are others. This was arbitrary.
Now, I have the function to gather the correct DPI. Except it complicates the code... :)

Also, don't know if its my environment (work office) that is the issue, firewall and etc... I could not install the module over the internet using the pip function in python. I had to install using the wheel file. not a major issue.

Exact steps for others to reproduce the error

  • Download the attached image or create one yourself with a DPI higher than 72
  • Load the image in Blender

Run bpy.data.images["300dpi.jpg"].resolution

300dpi.jpg

**System Information** Operating system: Windows-10-10.0.19041-SP0 64 Bits Graphics card: GeForce RTX 2070 SUPER/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 451.67 **Blender Version** Broken: version: 2.91.0, branch: master, commit date: 2020-11-25 08:34, hash: `0f45cab862` Worked: (newest version of Blender that worked as expected) **Short description of error** A bit of context first, I setup a Node group that helps me scale textures to real world scale. So I use the images DPI or PPM for this. Thus I scripted the inputs for the Node groups to automatically grab the relevant information. It works fine with PNG and TIF but not with JPEG. I use the script below to gather the DPI. For JPEGs, I get the wrong DPI, 72 dpi (2834.646 ppm). Even if the correct value should be higher, blender always displays 72dpi. To overcome this, I added a python module ExifRead. There are others. This was arbitrary. Now, I have the function to gather the correct DPI. Except it complicates the code... :) Also, don't know if its my environment (work office) that is the issue, firewall and etc... I could not install the module over the internet using the pip function in python. I had to install using the wheel file. not a major issue. **Exact steps for others to reproduce the error** - Download the attached image or create one yourself with a DPI higher than 72 - Load the image in Blender # Run `bpy.data.images["300dpi.jpg"].resolution` ![300dpi.jpg](https://archive.blender.org/developer/F9562726/300dpi.jpg)
Author

Added subscriber: @CharlesSemeon

Added subscriber: @CharlesSemeon

Added subscriber: @rjg

Added subscriber: @rjg

It seems that this isn't set for JPEG. In a cursory search in the source code only *.png, *.exr, *.tif and *.bmp seem to set the ppm on the ibuf which is used for the resolution property. From my current understanding this is a missing feature, but given that the Python API doesn't indicate that the resolution may not have been loaded from the files metadata, this could also be considered a bug.

It seems that this isn't set for JPEG. In a cursory search in the source code only *.png, *.exr, *.tif and *.bmp seem to set the `ppm` on the `ibuf` which is used for the `resolution` property. From my current understanding this is a missing feature, but given that the Python API doesn't indicate that the `resolution` may not have been loaded from the files metadata, this could also be considered a bug.

This issue was referenced by 6f88053d85

This issue was referenced by 6f88053d852ad7f04b3d67b1905d88917f481ee3
Member

Added subscriber: @lichtwerk

Added subscriber: @lichtwerk
Member

D10166 looks like it does the trick, not 100% sure though.

[D10166](https://archive.blender.org/developer/D10166) looks like it does the trick, not 100% sure though.
Member

Changed status from 'Needs Triage' to: 'Confirmed'

Changed status from 'Needs Triage' to: 'Confirmed'
Member

Since we have a patch, will confirm for now.

Since we have a patch, will confirm for now.
Member

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'
Philipp Oeser self-assigned this 2021-01-29 11:37:55 +01:00
Author

Hello, I am not sure it this is the place for me to post update on the issue.

I was a happy bunny when this was resolved but it does not work on all JPEGs.

I attached the image that does not retrieve the DPI. Also, to make it work I have to re-save in another program (irfan view) when I re-save in Photoshop the problem persist.

RED 300dpi.jpg

Hello, I am not sure it this is the place for me to post update on the issue. I was a happy bunny when this was resolved but it does not work on all JPEGs. I attached the image that does not retrieve the DPI. Also, to make it work I have to re-save in another program (irfan view) when I re-save in Photoshop the problem persist. ![RED 300dpi.jpg](https://archive.blender.org/developer/F9610197/RED_300dpi.jpg)
Member

Changed status from 'Resolved' to: 'Needs Triage'

Changed status from 'Resolved' to: 'Needs Triage'
Member

Changed status from 'Needs Triage' to: 'Needs User Info'

Changed status from 'Needs Triage' to: 'Needs User Info'
Member

Had a look and in contrast to 300dpi.jpg [which has its density_unit set to 1 correctly -- 1 corresponds to dots/inch], the other file you provided RED_300dpi.jpg has its density_unit set to 0 [0 corresponds to 'unknown'].
In case of 'unknown', there is not much we can/should do?

If I resave RED_300dpi.jpg from Gimp, it then has its density_unit set correctly to 1.

Does this help possibly?
https://community.adobe.com/t5/photoshop/how-to-export-a-jpeg-with-300dpi-ps-keeps-exporting-at-96dpi-even-though-image-res-is-set-to-300px/td-p/8146131

Had a look and in contrast to `300dpi.jpg` [which has its `density_unit` set to 1 correctly -- 1 corresponds to dots/inch], the other file you provided `RED_300dpi.jpg` has its `density_unit` set to 0 [0 corresponds to 'unknown']. In case of 'unknown', there is not much we can/should do? If I resave `RED_300dpi.jpg` from Gimp, it then has its `density_unit` set correctly to 1. Does this help possibly? https://community.adobe.com/t5/photoshop/how-to-export-a-jpeg-with-300dpi-ps-keeps-exporting-at-96dpi-even-though-image-res-is-set-to-300px/td-p/8146131
Author

Thanks for the reply.

The adobe community page does not solve the problem. Adobe still doesn't save with a density unit of 1.

So I will have to put warning signs to not use JPEGs in the setup. :)

Thanks for the reply. The adobe community page does not solve the problem. Adobe still doesn't save with a density unit of 1. So I will have to put warning signs to not use JPEGs in the setup. :)
Member

Changed status from 'Needs User Info' to: 'Resolved'

Changed status from 'Needs User Info' to: 'Resolved'
Member

Hi @CharlesSemeon .

This is a bit unfortunate, but I guess there is really not much we can do here.
Sorry to say, but will close again.
If you get any updates fro the Adobe side (or other information that would let us proceed on our side, please let us know!)

Hi @CharlesSemeon . This is a bit unfortunate, but I guess there is really not much we can do here. Sorry to say, but will close again. If you get any updates fro the Adobe side (or other information that would let us proceed on our side, please let us know!)
Author

Hello Philipp,

Not much of an update. Below is an answer I got from the Adobe community.

There are two different JPEG metadata containers, EXIF and JFIF. Many files contain elements from both, but you need to handle both formats. I use JPEGLib to parse JPEG files. I cannot suggest any Python solution, that's not my area. https:*en.wikipedia.org/wiki/JPEG_File_Interchange_Format

I tried to prove the information by looking for modules that can read JFIF. BUT I can not advance enough for this. I'll just stick to moving vertices.... :)

Hope this helps.

Regards,
Charles

Hello Philipp, Not much of an update. Below is an answer I got from the Adobe community. > There are two different JPEG metadata containers, EXIF and JFIF. Many files contain elements from both, but you need to handle both formats. I use JPEGLib to parse JPEG files. I cannot suggest any Python solution, that's not my area. [https:*en.wikipedia.org/wiki/JPEG_File_Interchange_Format](https:*en.wikipedia.org/wiki/JPEG_File_Interchange_Format#:~:text=Xthumbnail%20%C3%97%20Ythumbnail-,Compatibility,immediately%20follow%20the%20SOI%20marker) I tried to prove the information by looking for modules that can read JFIF. BUT I can not advance enough for this. I'll just stick to moving vertices.... :) Hope this helps. Regards, Charles
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#84661
No description provided.