bimg
bimg copied to clipboard
Basic cropping fails when image has EXIF orientation
Hello,
Trying to crop into an oriented image, I got the following error: extract_area: bad extract area
See the complete reproduction repository here.
package main
import (
"fmt"
"github.com/h2non/bimg"
"io/ioutil"
"os"
"path"
)
func main() {
cD, _ := os.Getwd()
fP := path.Join(cD, "data/Landscape_6.jpg")
fB, _ := ioutil.ReadFile(fP)
bI := bimg.NewImage(fB)
iS, _ := bI.Size()
iM, _ := bI.Metadata()
fmt.Printf("Image size: %+v\n", iS) // 1200 x 1800
fmt.Printf("Image orientation: %+v\n", iM.EXIF.Orientation) // 6
options := bimg.Options{
Top: 0,
Left: 0,
AreaWidth: 1000,
AreaHeight: 1800,
}
_, err := bI.Process(options)
fmt.Printf("Error: %+v\n", err) // extract_area: bad extract area
}
Despite that bimg returns (width, height) = (1200, 1800)
as image size, it seems to consider the orientation when trying to crop it.
When inverting AreaWidth
and AreaHeight
values, no error is thrown.
Were you able to find a solution to this?