Skip to content
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

Fix rendering of fnumber in EXIF data #86

Merged
merged 1 commit into from
Aug 12, 2024

Conversation

ramatevish
Copy link
Contributor

FNumber is represented as a imagemeta.rat[uint32], which contains a numerator and a denominator. If used directly in a template this results in fractional apertures (e.g. 5.6) in their rational form (e.g. 28/5) rather than as a float with one sig fig.

This commit updates the EXIF rendering logic, casting the rational to a float64, and then rendering it with at most 1 sig fig.

Before:
Screenshot 2024-08-09 at 8 35 27 PM
After:
Screenshot 2024-08-09 at 8 35 02 PM

I looked at example photos with both rational and integer apertures, and didn't see any issues, though this wasn't exhaustive.

FNumber is represented as a imagemeta.rat[uint32], which contains a numerator and a denominator. If used directly in a template this results in fractional apertures (e.g. 5.6) in their rational form (e.g. 28/5) rather than as a float with one sig fig. 

This commit updates the EXIF rendering logic, casting the rational to a float64, and then rendering it with at most 1 sig fig
@mfg92
Copy link
Owner

mfg92 commented Aug 11, 2024

Thanks for your contribution. What version of Hugo are you using? I am running into this problem:

execute of template failed at <.FNumber.Float64>: can’t evaluate field Float64 in type interface {}

I'm using Hugo 0.129.0. Because of a bug in 0.130.0 and 0.131.0 I'm stuck whith that older version. Fortunately, this bug is already fixed in main.

@mfg92
Copy link
Owner

mfg92 commented Aug 12, 2024

Hugo 0.132.0 has been released and contains the fix I have been waiting for. With this version I can reproduce the problem you are having with the apperture number.
My analysis shows: The change of the library (introduced in version 0.130.0) that is used by Hugo to read the image metadata must have changed how .FNumber behaves.
Your solution fixes this. However, it also raises the minimum supported Hugo version to 0.130.0.

I also noticed that ISO is no longer displayed with the new version of Hugo. This is caused by the renaming of the corresponding field in the metadata object. I will fix that after the merge.

@mfg92 mfg92 merged commit a9d95ca into mfg92:master Aug 12, 2024
@ramatevish
Copy link
Contributor Author

This was run on v0.131.0

> hugo -v
hugo v0.131.0-bfbee17932ff24009008aa94cdd75c0c41f59279+extended linux/arm64 BuildDate=2024-08-02T09:03:48Z VendorInfo=hugomods

@mfg92
Copy link
Owner

mfg92 commented Aug 14, 2024

This is now part of of v1.3.0. Thanks a lot for your contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants