Move code using the 'kovidgoyal/imaging' package to separate files to make it easier to create alternative implementations based on build tags.
21 lines
469 B
Go
21 lines
469 B
Go
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
|
|
}
|