Add image.Exif

Note that we will probably need to add some metadata cache for this to scale.

Fixes #4600
This commit is contained in:
Bjørn Erik Pedersen
2019-08-29 10:18:51 +02:00
parent 8a8d4a6d97
commit 28143397d6
12 changed files with 483 additions and 2 deletions

View File

@@ -119,6 +119,11 @@ func DecodeConfig(m map[string]interface{}) (Imaging, error) {
i.ResampleFilter = filter
}
if strings.TrimSpace(i.Exif.IncludeFields) == "" && strings.TrimSpace(i.Exif.ExcludeFields) == "" {
// Don't change this for no good reason. Please don't.
i.Exif.ExcludeFields = "GPS|Exif|Exposure[M|P|B]|Contrast|Resolution|Sharp|JPEG|Metering|Sensing|Saturation|ColorSpace|Flash|WhiteBalance"
}
return i, nil
}
@@ -279,4 +284,29 @@ type Imaging struct {
// The anchor to use in Fill. Default is "smart", i.e. Smart Crop.
Anchor string
Exif ExifConfig
}
type ExifConfig struct {
// Regexp matching the Exif fields you want from the (massive) set of Exif info
// available. As we cache this info to disk, this is for performance and
// disk space reasons more than anything.
// If you want it all, put ".*" in this config setting.
// Note that if neither this or ExcludeFields is set, Hugo will return a small
// default set.
IncludeFields string
// Regexp matching the Exif fields you want to exclude. This may be easier to use
// than IncludeFields above, depending on what you want.
ExcludeFields string
// Hugo extracts the "photo taken" date/time into .Date by default.
// Set this to true to turn it off.
DisableDate bool
// Hugo extracts the "photo taken where" (GPS latitude and longitude) into
// .Long and .Lat. Set this to true to turn it off.
DisableLatLong bool
}