feat: autorotate

This commit is contained in:
Tomas 2020-08-04 19:40:07 +02:00
parent 0ae3ac43ce
commit 26b22e9a6f
28 changed files with 105 additions and 2 deletions

View file

@ -30,10 +30,20 @@ func resizer(buf []byte, o Options) ([]byte, error) {
// Clone and define default options
o = applyDefaults(o, imageType)
// Ensure supported type
if !IsTypeSupported(o.Type) {
return nil, errors.New("Unsupported image output type")
}
// Autorate only
if o.autoRotateOnly {
image, err = vipsAutoRotate(image)
if err != nil {
return nil, err
}
return saveImage(image, o)
}
// Auto rotate image based on EXIF orientation header
image, rotated, err := rotateAndFlipImage(image, o)
if err != nil {
@ -375,7 +385,6 @@ func watermarkImageWithText(image *C.VipsImage, w Watermark) (*C.VipsImage, erro
}
func watermarkImageWithAnotherImage(image *C.VipsImage, w WatermarkImage) (*C.VipsImage, error) {
if len(w.Buf) == 0 {
return image, nil
}