Bug 708433 - Image resolutions in stext device always are the same (xres = yres = 96)
Summary: Image resolutions in stext device always are the same (xres = yres = 96)
Status: RESOLVED WONTFIX
Alias: None
Product: MuPDF
Classification: Unclassified
Component: mupdf (show other bugs)
Version: unspecified
Hardware: All All
: P2 normal
Assignee: MuPDF bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-04-09 09:40 UTC by Jorj
Modified: 2025-04-16 15:05 UTC (History)
1 user (show)

See Also:
Customer:
Word Size: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jorj 2025-04-09 09:40:53 UTC
PyMuPDF issue https://github.com/pymupdf/PyMuPDF/issues/4433
Example file https://media3.bosch-home.com/Documents/specsheet/nl-NL/WGG246Z5NL.pdf

All images returned by the stext device have image->xres = 96 and image->yres = 96
although, when the image is saved with the corresponding extension, other resolutions are reported - e.g. JPEGs extracted via mutool also have x/y resolutions 299.
Comment 1 Robin Watts 2025-04-16 15:05:21 UTC
All images in PDF are created with 96dpi as their default xres/yres. This is because this value makes no difference to how they are used within a PDF file.

Many PDF images don't have any actual xres/yres values to read (for instance raw/LZW/Zlib compressed ones). Other formats (such as JPEGs) do have xres/yres values, but to get them, we'd need to decode the format, and we delay doing that for as long as possible.

It's important to understand why the user might want these values. If they want to know the xres/yres of the raw images used within a PDF file, then decode to a pixmap and interrogate that. But those values will not be related to how the images are actually used.

Consider a single image in a PDF may be used repeatedly on one (or many) pages at different scales. The interesting thing is then what the effective resolution is for each instance of that image. And that can only be calculated by looking at how each usage of the the image is used.

This can be done from the data in the stext blocks (transform and image w/h).

As such, I don't think there is anything we can change in MuPDF to improve things.