mirror of
https://github.com/talgo-cloud/bimg.git
synced 2026-03-16 19:05:54 -07:00
feat: autorotate
This commit is contained in:
parent
0ae3ac43ce
commit
26b22e9a6f
28 changed files with 105 additions and 2 deletions
11
resizer.go
11
resizer.go
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue