Image EXIF reading, missing LensModel

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.

image

Did I’ve missed something ?

Thanks for your help :slight_smile:

I’m guessing, but …

See the include/exclude fields in EXIF config: Image processing | Hugo

The default value (I have added some details for that now) does not include LensModel. If you set includeFields=".*" you will get everything.

Thanks for your answer. I’ve added this instruction and I have more data, but sadly not the LensModel.

Date: 2022-01-06 15:03:29 +0100 CET Lat/Long: 0/0 Tags:
TAG: Artist: Seb
TAG: CFAPattern:
TAG: ColorSpace: 1
TAG: Contrast: 0
TAG: Copyright: Creative Commons Attribution-ShareAlike (CC BY-SA)
TAG: CustomRendered: 0
TAG: DateTime: 2022-01-11 16:13:27 +0100 CET
TAG: DateTimeDigitized: 2022-01-06 15:03:29 +0100 CET
TAG: DateTimeOriginal: 2022-01-06 15:03:29 +0100 CET
TAG: DigitalZoomRatio: 1/1
TAG: ExifIFDPointer: 432
TAG: ExposureBiasValue: 0
TAG: ExposureMode: 0
TAG: ExposureProgram: 3
TAG: ExposureTime: 0.03333333333333333
TAG: FNumber: 1.8
TAG: FileSource:
TAG: Flash: 16
TAG: FocalLength: 35
TAG: FocalLengthIn35mmFilm: 52
TAG: GainControl: 2
TAG: ISOSpeedRatings: 3200
TAG: ImageDescription:
TAG: LightSource: 0
TAG: Make: NIKON CORPORATION
TAG: MakerNote: NikonII < big binary data>
TAG: MaxApertureValue: 1.6
TAG: MeteringMode: 5
TAG: Model: NIKON D5600
TAG: Orientation: 1
TAG: PixelXDimension: 1280
TAG: PixelYDimension: 855
TAG: ResolutionUnit: 2
TAG: Saturation: 0
TAG: SceneCaptureType: 0
TAG: SceneType:
TAG: SensingMethod: 2
TAG: Sharpness: 0
TAG: Software: darktable 3.6.1
TAG: SubSecTime: 83
TAG: SubSecTimeDigitized: 83
TAG: SubSecTimeOriginal: 83
TAG: SubjectDistanceRange: 0
TAG: WhiteBalance: 0
TAG: XResolution: 300
TAG: YResolution: 300

BTW, I’ve forgot to display the Hugo env :

hugo v0.91.2-1798BD3F linux/amd64 BuildDate=2021-12-23T15:33:34Z VendorInfo=gohugoio
GOOS="linux"
GOARCH="amd64"
GOVERSION="go1.17.5"

If it may help : here is a link to a photo which should return the LensModel, the article wasn’t published at the time I’ve opened this request.

Here’s a test repo with two images:

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:

  1. It is not necessary to set imaging.exif.includeFields to ".*" in order to obtain LensMake or LensModel

  2. 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
  3. 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.

1 Like

I confirm that with the sample images, the Lens Model is correctly returned by the .Tag.LensModel field in my shortcode.

{{< exif-full src="photos/Nikon1AW1.jpg" alt="test" >}}

TAG: LensModel: 1 NIKKOR AW 11-27.5mm f/3.5-5.6

As gThumb displayed the Lens Model, I didn’t suspected an image issue at first. Thanks for the analysis material, I’ll search this way.

Edit : after checking my photo with exiftool, the populated field is Lens ID, not Lens Model.

$ exiftool DSC_0021.jpg |grep -i lens
Lens ID                         : AF-S DX Nikkor 35mm f/1.8G

That must be a flaw in my Darktable configuration.

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.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.