refactor(thumbnails): separate out 'kovidgoyal/imaging' dependencies

Move code using the 'kovidgoyal/imaging' package to separate files
to make it easier to create alternative implementations based on build
tags.
This commit is contained in:
Ralf Haferkamp
2024-10-17 14:05:27 +02:00
committed by Ralf Haferkamp
parent d0ce57dfc2
commit 358adc15dc
8 changed files with 137 additions and 97 deletions
@@ -27,18 +27,6 @@ type FileConverter interface {
Convert(r io.Reader) (interface{}, error)
}
// ImageDecoder is a converter for the image file
type ImageDecoder struct{}
// Convert reads the image file and returns the thumbnail image
func (i ImageDecoder) Convert(r io.Reader) (interface{}, error) {
img, err := imaging.Decode(r, imaging.AutoOrientation(true))
if err != nil {
return nil, errors.Wrap(err, `could not decode the image`)
}
return img, nil
}
// GifDecoder is a converter for the gif file
type GifDecoder struct{}
@@ -0,0 +1,20 @@
package preprocessor
import (
"io"
"github.com/kovidgoyal/imaging"
"github.com/pkg/errors"
)
// ImageDecoder is a converter for the image file
type ImageDecoder struct{}
// Convert reads the image file and returns the thumbnail image
func (i ImageDecoder) Convert(r io.Reader) (interface{}, error) {
img, err := imaging.Decode(r, imaging.AutoOrientation(true))
if err != nil {
return nil, errors.Wrap(err, `could not decode the image`)
}
return img, nil
}