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

EXIF FNumber is printed in an unexpected form #12718

Closed
Fethbita opened this issue Aug 5, 2024 · 3 comments
Closed

EXIF FNumber is printed in an unexpected form #12718

Fethbita opened this issue Aug 5, 2024 · 3 comments
Assignees
Milestone

Comments

@Fethbita
Copy link

Fethbita commented Aug 5, 2024

When using the following shortcode:

  {{ range $index, $image := (sort (resources.Match (.Get 0)) "Exif.Date" "desc") }}
    <figure>
    <img src="{{ $image.RelPermalink }}" alt="{{ $image.Exif.Tags.ImageDescription }}">
    {{ $image_properties := printf "%s sec, f/%s, ISO %d"  $image.Exif.Tags.ExposureTime $image.Exif.Tags.FNumber $image.Exif.Tags.ISO }}
    <figcaption>{{ $image_properties }}</figcaption>
    </figure>
  {{ end }}

The result is unexpected. For FNumber 3.6, 18/5 is shown:
image

If the FNumber is printed with format string %f, the following appears instead:

1/2000 sec, f/&{%!f(uint32=18) %!f(uint32=5)}, ISO 160

I think it might be related to #12651.

What version of Hugo are you using (hugo version)?

$ hugo version
hugo v0.131.0+extended

Does this issue reproduce with the latest release?

Yes

@bep bep removed the NeedsTriage label Aug 5, 2024
@bep bep self-assigned this Aug 5, 2024
@bep bep added this to the v0.131.0 milestone Aug 5, 2024
@bep
Copy link
Member

bep commented Aug 5, 2024

Thanks for the report. I will try to improve the printf support for the rat type in the new imagemeta library.

What you can try as a workaround is something like:

$f := $image.Exif.Tags.FNumber.Float64
// ... format it with %f

@Fethbita
Copy link
Author

Fethbita commented Aug 5, 2024

Yup, the workaround works:

    {{ $aperture := $image.Exif.Tags.FNumber.Float64 }}
    {{ $image_properties := printf "%s sec, f/%.1f, ISO %d"  $image.Exif.Tags.ExposureTime $aperture $image.Exif.Tags.ISO }}

Thank you for the quick response.

bep added a commit to bep/imagemeta that referenced this issue Aug 5, 2024
@bep bep closed this as completed in 8f8d12a Aug 6, 2024
bep added a commit to bep/hugo that referenced this issue Aug 6, 2024
Make it support the new upstream rational number type in Exif.

See gohugoio#12718
bep added a commit to bep/hugo that referenced this issue Aug 6, 2024
Make it support the new upstream rational number type in Exif.

See gohugoio#12718
bep added a commit that referenced this issue Aug 6, 2024
Make it support the new upstream rational number type in Exif.

See #12718
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants