I’d like to have a way to get the DPI value(s) for a (local) image resource.
In my render-image.html
render hook I’ve something like this:
{{- with .Page.Resources.GetMatch .Destination -}}
<img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" />
{{- end -}}
And I’d like to have a .Dpi
(or: .DpiX
and .DpiY
) property here.
(Before creating a feature proposal on GitHub, I thought I’d ask here first.)
My use case:
I often use screenshots in my Hugo pages:
![My Screenshot](my-screenshot.png)
When I record a, say 100x100 pixels, screenshot on a high DPI/4K display, the screenshot tool properly records the DPI values as 192/192 (which is double of the standard 96 DPI on a 1K display).
The downside is that browsers now display the image at 200x200 pixels (because that’s the “native” pixel size of the image) - but I’d rather display it at 100x100 pixels.
If I could get the DPI values in Hugo, I could automatically calculate a scaling factor (by dividing the DPI size by 96).
Here’s an example of such a screenshot: