Exif
適用於 JPEG、PNG、TIFF 和 WebP 圖像,Exif
方法作用於圖像的 Resource
物件,返回一個包含圖像元資料的 EXIF 物件。
方法
- Date
- (
time.Time
) 返回圖像創建的日期/時間。使用time.Format
函數格式化。 - Lat
- (
float64
) 返回 GPS 緯度,單位為度。 - Long
- (
float64
) 返回 GPS 經度,單位為度。 - Tags
- (
exif.Tags
) 返回此圖像的可用 EXIF 標籤集合。您可以在 [站點配置] 中包含或排除此集合中的特定標籤。
範例
列出創建日期、位置和 EXIF 標籤:
{{ with resources.Get "images/a.jpg" }}
{{ with .Exif }}
<p>日期: {{ .Date }}</p>
<p>緯度/經度: {{ .Lat }}/{{ .Long }}</p>
{{ with .Tags }}
<p>標籤</p>
<table>
<thead>
<tr><th>標籤</th><th>值</th></tr>
</thead>
<tbody>
{{ range $k, $v := . }}
<tr><td>{{ $k }}</td><td>{{ $v }}</td></tr>
{{ end }}
</tbody>
</table>
{{ end }}
{{ end }}
{{ end }}
列出特定值:
{{ with resources.Get "images/a.jpg" }}
{{ with .Exif }}
<ul>
{{ with .Date }}<li>日期: {{ .Format "January 02, 2006" }}</li>{{ end }}
{{ with .Tags.ApertureValue }}<li>光圈值: {{ lang.FormatNumber 2 . }}</li>{{ end }}
{{ with .Tags.BrightnessValue }}<li>亮度: {{ lang.FormatNumber 2 . }}</li>{{ end }}
{{ with .Tags.ExposureTime }}<li>曝光時間: {{ . }}</li>{{ end }}
{{ with .Tags.FNumber }}<li>F 值: {{ . }}</li>{{ end }}
{{ with .Tags.FocalLength }}<li>焦距: {{ . }}</li>{{ end }}
{{ with .Tags.ISOSpeedRatings }}<li>ISO 速率: {{ . }}</li>{{ end }}
{{ with .Tags.LensModel }}<li>鏡頭型號: {{ . }}</li>{{ end }}
</ul>
{{ end }}
{{ end }}