Files
hugo/docs/content/en/methods/resource/Exif.md
T
Bjørn Erik Pedersen 30a20122b7 Merge commit '8f3c066d23f431fb2c53d97ea489e4c28b42bd82'
# Conflicts:
#	docs/data/docs.yaml
2026-02-14 12:14:33 +01:00

2.6 KiB

title, description, categories, keywords, params
title description categories keywords params
Exif Applicable to JPEG, PNG, TIFF, and WebP images, returns an object containing Exif metadata.
metadata
functions_and_methods
returnType signatures
meta.ExifInfo
RESOURCE.Exif

{{% include "/_common/methods/resource/global-page-remote-resources.md" %}}

Applicable to JPEG, PNG, TIFF, and WebP images, the Exif method on an image Resource object returns an object containing Exif metadata.

To extract Exif, IPTC, and XMP metadata, use the Meta method instead.

Note

Metadata is not preserved during image transformation. Use this method with the original image resource to extract metadata from JPEG, PNG, TIFF, and WebP images.

Methods

Date

(time.Time) Returns the image creation date/time. Format with the time.Format function.

Lat

(float64) Returns the GPS latitude in degrees from Exif metadata.

Long

(float64) Returns the GPS longitude in degrees from Exif metadata.

Tags

(meta.Tags) Returns a collection of available Exif fields for this image. Availability is determined by the includeFields and excludeFields settings in your site configuration.

Examples

To list the creation date, latitude, and longitude:

{{ with resources.Get "images/a.jpg" }}
  {{ with .Exif }}
    <pre>
      {{ printf "%-25s %v\n" "Date" .Date }}
      {{ printf "%-25s %v\n" "Latitude" .Lat }}
      {{ printf "%-25s %v\n" "Longitude" .Long }}
    </pre>
  {{ end }}
{{ end }}

To list the available Exif fields:

{{ with resources.Get "images/a.jpg" }}
  {{ with .Exif }}
    <pre>
      {{ range $k, $v := .Tags -}}
        {{ printf "%-25s %v\n" $k $v }}
      {{ end }}
    </pre>
  {{ end }}
{{ end }}

To list specific Exif fields:

{{ with resources.Get "images/a.jpg" }}
  {{ with .Exif }}
    <pre>
      {{ with .Tags.ApertureValue }}{{ printf "%-25s %v\n" "ApertureValue" . }}{{ end }}
      {{ with .Tags.BrightnessValue }}{{ printf "%-25s %v\n" "BrightnessValue" . }}{{ end }}
    </pre>
  {{ end }}
{{ end }}