Skip to content

Commit

Permalink
test(vips): update golden files
Browse files Browse the repository at this point in the history
  • Loading branch information
cshum authored Sep 2, 2023
1 parent 08393ac commit 920bd72
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 1 deletion.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added testdata/gopher-exif-orientation-cw90.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 12 additions & 1 deletion vips/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,18 @@ func (v *Processor) Thumbnail(

// FocalThumbnail handles thumbnail with custom focal point
func (v *Processor) FocalThumbnail(img *Image, w, h int, fx, fy float64) (err error) {
if float64(w)/float64(h) > float64(img.Width())/float64(img.PageHeight()) {

var imageWidth, imageHeight float64
// exif orientation greater 5-8 are 90 or 270 degrees, w and h swapped
if img.Orientation() > 4 {
imageWidth = float64(img.PageHeight())
imageHeight = float64(img.Width())
} else {
imageWidth = float64(img.Width())
imageHeight = float64(img.PageHeight())
}

if float64(w)/float64(h) > float64(imageWidth)/float64(imageHeight) {
if err = img.Thumbnail(w, v.MaxHeight, InterestingNone); err != nil {
return
}
Expand Down
1 change: 1 addition & 0 deletions vips/processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ func TestProcessor(t *testing.T) {
{name: "resize focal float", path: "300x100/filters:fill(white):format(jpeg):focal(0.35x0.25:0.6x0.3)/gopher.png"},
{name: "resize focal point", path: "300x100/filters:fill(white):format(jpeg):focal(589x401):focal(1000x814)/gopher.png"},
{name: "resize focal point edge", path: "300x100/filters:fill(white):format(jpeg):focal(9999x9999)/gopher.png"},
{name: "resize focal point exif orientation cw90", path: "300x300/filters:format(jpeg):focal(150:150)/gopher-exif-orientation-cw90.png"},
{name: "resize top", path: "200x100/top/filters:quality(70):format(tiff)/gopher.png"},
{name: "resize top", path: "200x100/right/top/gopher.png"},
{name: "resize bottom", path: "200x100/bottom/gopher.png"},
Expand Down

0 comments on commit 920bd72

Please sign in to comment.