Hello,
I’m currently adding a shorcode in my template to extract the EXIF metadata from my photos.
Thanks to a lot a good answers I’ve found here and in the documentation (especially the exposure time formater, thanks a lot for this one !), I’ve been able to have a result. However, there is one data missing, the Lens Model.
Here is my shortcode :
{{- $imageName := .Get "src" -}}
{{- $alt := .Get "alt" -}}
{{- $originalImage := resources.Get $imageName -}}
<figure>
<img src="/{{ $imageName }}" alt="{{ $alt }}">
{{ with $originalImage.Exif }}
<figcaption>{{ $alt }}
<br />{{with .Tags.Model }}{{ . }} {{ end }} {{with .Tags.LensModel }}{{ . }} {{ end }} {{ with .Tags.FNumber }}<i>f</i>{{ . }} {{ end }} {{ with .Tags.FocalLength }} {{ . }}mm{{ end }} {{ with .Tags.ExposureTime }} {{ partial "format-exposure-time.html" . }} {{ end }} {{ with .Tags.ISOSpeedRatings }} ISO {{ . }}{{ end }}
<br />{{with .Tags.Artist }}{{ . }} - {{ end }} {{with .Tags.DateTime }} {{ . }} - {{ end }} {{ with .Tags.Copyright}}{{ . }}{{ end }}
</figcaption>
{{end }}
</figure>
<p>to see all available tags name</p>
{{ with $originalImage.Exif }}
Date: {{ .Date }}
Lat/Long: {{ .Lat}}/{{ .Long }}
Tags:
{{ range $k, $v := .Tags }}
<li>TAG: {{ $k }}: {{ $v }}</li>
{{ end }}
{{ end }}
I have the expected result :
{{< exif src="photos/DSC_0011.jpg" alt="test" >}}
[the image]
test
NIKON D5600 f1.8 35mm 1/30 s ISO 6400
Seb - 2022-01-11 16:13:30 +0100 CET - Creative Commons Attribution-ShareAlike (CC BY-SA)
According to Darktable and other image viewer like gThumb, the Lens Model field is properly filled.
git clone --single-branch -b hugo-forum-topic-36506 https://github.com/jmooring/hugo-testing hugo-forum-topic-36506
cd hugo-forum-topic-36506
hugo server
Findings:
It is not necessary to set imaging.exif.includeFields to ".*" in order to obtain LensMake or LensModel
These additional Lens tags are not available to Hugo regardless of imaging.exif.includeFields
Lens
Lens Data Version
Lens F Stops
Lens Info
Lens Serial Number
Lens Spec
Lens Type
When I run DSC_0021.jpg through Phil Harvey’s exiftool the Lens Make and Lens Model are not displayed.
$exiftool content/tests/test-2/DSC_0021.jpg | grep -i lens
Lens Type : G
Lens : 35mm f/1.8
Lens F Stops : 7.33
Lens Spec : 35mm f/1.8 G
So it seems like a problem with this particular image.
Confirmed, the LensModel field was not filled. (if anyone has the same problem, here is the issue that helped me).
The only thing I’ve noticed about Hugo is that it doesn’t read the LensID field which was filled. I’m not sure if it’s a real issue so I won’t bother you with that.