-
Couldn't load subscription status.
- Fork 206
fix(thumbs): WPB-21131 generate thumbs with the exif orientation #686
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
10d30d1
ec45317
3c5af9e
ac3b57c
c56141f
e2ac2e1
e9daad0
4042192
82e0de7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,7 @@ import ( | |
| "image/color" | ||
| "io" | ||
|
|
||
| "github.com/disintegration/imageorient" | ||
| "github.com/disintegration/imaging" | ||
| _ "golang.org/x/image/tiff" | ||
| _ "golang.org/x/image/webp" | ||
|
|
@@ -39,6 +40,7 @@ const ( | |
| BMP | ||
| WEBP | ||
| TIFF | ||
| GIF | ||
| ) | ||
|
|
||
| // ResizeFilter represents the resizing algorithm | ||
|
|
@@ -82,7 +84,13 @@ func NewImageCodec(fileExt string) ImageCodec { | |
|
|
||
| // Decode reads an image from the provided reader | ||
| func (c defaultCodec) Decode(reader io.Reader) (image.Image, error) { | ||
| return imaging.Decode(reader) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry to bother again :-) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There might be a minor performance hit. For our case I believe is better to configure it upon decoder instantiation, to avoid having non-intuitive rotation only for one format type. Something like: t.codec = encoding.NewImageCodec(fileFormat, &encoding.CodecOptions{
EnforceExifOrientation: true,
})Then in case is not enforced it uses the standard encoding There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I notice also that there are some img types that simply don't support exif at all, for instance, GIF / BMP. I see the underlining library handle these already |
||
| // Formats that don't support EXIF, so we avoid the extra processing | ||
| if c.format == GIF || c.format == BMP { | ||
| return imaging.Decode(reader) | ||
| } | ||
|
|
||
| img, _, err := imageorient.Decode(reader) | ||
| return img, err | ||
| } | ||
|
|
||
| // Encode writes an image to the provided writer in the specified format | ||
|
|
@@ -139,6 +147,8 @@ func extensionToFormat(ext string) ImageFormat { | |
| return WEBP | ||
| case ".tiff", ".tif": | ||
| return TIFF | ||
| case ".gif": | ||
| return GIF | ||
| default: | ||
| return JPEG | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can replace this library as a next step