Fix images.AutoOrient regression

Broken in v0.130.0. Added a integration test to avoid future breakage.

Fixes #12712
This commit is contained in:
Bjørn Erik Pedersen
2024-08-02 09:37:00 +02:00
parent 914fa13efd
commit 944fcc216f
3 changed files with 39 additions and 1 deletions

View File

@@ -19,6 +19,7 @@ import (
"github.com/disintegration/gift"
"github.com/gohugoio/hugo/resources/images/exif"
"github.com/spf13/cast"
)
var _ gift.Filter = (*autoOrientFilter)(nil)
@@ -49,7 +50,8 @@ func (f autoOrientFilter) Bounds(srcBounds image.Rectangle) image.Rectangle {
func (f autoOrientFilter) AutoOrient(exifInfo *exif.ExifInfo) gift.Filter {
if exifInfo != nil {
if orientation, ok := exifInfo.Tags["Orientation"].(int); ok {
if v, ok := exifInfo.Tags["Orientation"]; ok {
orientation := cast.ToInt(v)
if filter, ok := transformationFilters[orientation]; ok {
return filter
}