diff --git a/.travis.yml b/.travis.yml index fa62cfc..1605932 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,28 +4,26 @@ dist: trusty sudo: false go: - # - "1.10" - #- "1.11" - "1.12" - "1.13" - # - "tip" + - "1.14" env: - # - LIBVIPS=7.42.3 - # - LIBVIPS=8.2.3 + - LIBVIPS=7.42.3 # - LIBVIPS=8.3.3 - # - LIBVIPS=8.4.6 - # - LIBVIPS=8.5.8 + - LIBVIPS=8.4.6 + - LIBVIPS=8.5.8 - LIBVIPS=8.6.2 + - LIBVIPS=8.7.4 - LIBVIPS=8.8.4 - - LIBVIPS=8.9.1 + - LIBVIPS=8.9.2 - LIBVIPS=master matrix: allow_failures: - - env: LIBVIPS=7.42.3 - - env: LIBVIPS=8.2.3 - - env: LIBVIPS=8.3.3 + - env: LIBVIPS=7.42.3 + - env: LIBVIPS=8.4.6 + - env: LIBVIPS=master cache: apt: diff --git a/resizer.go b/resizer.go index a76944f..d6e2cb3 100644 --- a/resizer.go +++ b/resizer.go @@ -383,7 +383,7 @@ func watermarkImageWithAnotherImage(image *C.VipsImage, w WatermarkImage) (*C.Vi func imageFlatten(image *C.VipsImage, imageType ImageType, o Options) (*C.VipsImage, error) { // Only PNG images are supported for now - if imageType != PNG || o.Background == ColorBlack { + if o.Background == ColorBlack || (imageType != PNG && imageType != HEIF && imageType != WEBP) { return image, nil } return vipsFlattenBackground(image, o.Background) diff --git a/resizer_test.go b/resizer_test.go index 6a116a2..4b2d4a1 100644 --- a/resizer_test.go +++ b/resizer_test.go @@ -40,7 +40,7 @@ func TestResizeVerticalImage(t *testing.T) { {Width: 1000, Height: 1500}, {Width: 1000}, {Height: 1500}, - {Width: 100, Height: 50}, + {Width: 200, Height: 120}, {Width: 2000, Height: 2000}, {Width: 500, Height: 1000}, {Width: 500}, @@ -72,7 +72,7 @@ func TestResizeVerticalImage(t *testing.T) { for _, options := range tests { image, err := Resize(source.buf, options) if err != nil { - t.Errorf("Resize(imgData, %#v) error: %#v", options, err) + t.Fatalf("Resize(imgData, %#v) error: %#v", options, err) } format := DetermineImageType(image) diff --git a/testdata/exif/Landscape_1_out.jpg b/testdata/exif/Landscape_1_out.jpg index 1ffcaaf..0f7ca1f 100644 Binary files a/testdata/exif/Landscape_1_out.jpg and b/testdata/exif/Landscape_1_out.jpg differ diff --git a/testdata/exif/Landscape_2_out.jpg b/testdata/exif/Landscape_2_out.jpg index aab8a2a..7f71884 100644 Binary files a/testdata/exif/Landscape_2_out.jpg and b/testdata/exif/Landscape_2_out.jpg differ diff --git a/testdata/exif/Landscape_3_out.jpg b/testdata/exif/Landscape_3_out.jpg index a7132c7..c487686 100644 Binary files a/testdata/exif/Landscape_3_out.jpg and b/testdata/exif/Landscape_3_out.jpg differ diff --git a/testdata/exif/Landscape_4_out.jpg b/testdata/exif/Landscape_4_out.jpg index 95b8ea9..39533f6 100644 Binary files a/testdata/exif/Landscape_4_out.jpg and b/testdata/exif/Landscape_4_out.jpg differ diff --git a/testdata/exif/Landscape_5_out.jpg b/testdata/exif/Landscape_5_out.jpg index 5227db8..2edad25 100644 Binary files a/testdata/exif/Landscape_5_out.jpg and b/testdata/exif/Landscape_5_out.jpg differ diff --git a/testdata/exif/Landscape_6_out.jpg b/testdata/exif/Landscape_6_out.jpg index ea031f7..7e8044f 100644 Binary files a/testdata/exif/Landscape_6_out.jpg and b/testdata/exif/Landscape_6_out.jpg differ diff --git a/testdata/exif/Landscape_7_out.jpg b/testdata/exif/Landscape_7_out.jpg index 0e6350b..0bb5462 100644 Binary files a/testdata/exif/Landscape_7_out.jpg and b/testdata/exif/Landscape_7_out.jpg differ diff --git a/testdata/exif/Landscape_8_out.jpg b/testdata/exif/Landscape_8_out.jpg index 04f6b2c..995f310 100644 Binary files a/testdata/exif/Landscape_8_out.jpg and b/testdata/exif/Landscape_8_out.jpg differ diff --git a/testdata/exif/Portrait_1_out.jpg b/testdata/exif/Portrait_1_out.jpg index e3af98c..4c46526 100644 Binary files a/testdata/exif/Portrait_1_out.jpg and b/testdata/exif/Portrait_1_out.jpg differ diff --git a/testdata/exif/Portrait_2_out.jpg b/testdata/exif/Portrait_2_out.jpg index 5c5366f..0c68143 100644 Binary files a/testdata/exif/Portrait_2_out.jpg and b/testdata/exif/Portrait_2_out.jpg differ diff --git a/testdata/exif/Portrait_3_out.jpg b/testdata/exif/Portrait_3_out.jpg index 8a8da00..55e44ca 100644 Binary files a/testdata/exif/Portrait_3_out.jpg and b/testdata/exif/Portrait_3_out.jpg differ diff --git a/testdata/exif/Portrait_4_out.jpg b/testdata/exif/Portrait_4_out.jpg index 2528749..23eae85 100644 Binary files a/testdata/exif/Portrait_4_out.jpg and b/testdata/exif/Portrait_4_out.jpg differ diff --git a/testdata/exif/Portrait_5_out.jpg b/testdata/exif/Portrait_5_out.jpg index c2b2ff3..51ca714 100644 Binary files a/testdata/exif/Portrait_5_out.jpg and b/testdata/exif/Portrait_5_out.jpg differ diff --git a/testdata/exif/Portrait_6_out.jpg b/testdata/exif/Portrait_6_out.jpg index a13b3f1..867eda8 100644 Binary files a/testdata/exif/Portrait_6_out.jpg and b/testdata/exif/Portrait_6_out.jpg differ diff --git a/testdata/exif/Portrait_7_out.jpg b/testdata/exif/Portrait_7_out.jpg index e64cc8d..e9d4989 100644 Binary files a/testdata/exif/Portrait_7_out.jpg and b/testdata/exif/Portrait_7_out.jpg differ diff --git a/testdata/exif/Portrait_8_out.jpg b/testdata/exif/Portrait_8_out.jpg index ffe52aa..71c42ab 100644 Binary files a/testdata/exif/Portrait_8_out.jpg and b/testdata/exif/Portrait_8_out.jpg differ diff --git a/testdata/test_gif.jpg b/testdata/test_gif.jpg index d2ae362..1e8c2aa 100644 Binary files a/testdata/test_gif.jpg and b/testdata/test_gif.jpg differ diff --git a/testdata/test_pdf.jpg b/testdata/test_pdf.jpg index f80af8b..7a1ba3c 100644 Binary files a/testdata/test_pdf.jpg and b/testdata/test_pdf.jpg differ diff --git a/testdata/test_smart_crop.jpg b/testdata/test_smart_crop.jpg index 5acb94a..f5d928b 100644 Binary files a/testdata/test_smart_crop.jpg and b/testdata/test_smart_crop.jpg differ diff --git a/testdata/test_svg.jpg b/testdata/test_svg.jpg index dba7747..a8a1b40 100644 Binary files a/testdata/test_svg.jpg and b/testdata/test_svg.jpg differ diff --git a/type_test.go b/type_test.go index f3ee219..b06e251 100644 --- a/type_test.go +++ b/type_test.go @@ -18,7 +18,7 @@ func TestDeterminateImageType(t *testing.T) { {"test.gif", GIF}, {"test.pdf", PDF}, {"test.svg", SVG}, - {"test.jp2", MAGICK}, + // {"test.jp2", MAGICK}, {"test.heic", HEIF}, {"test2.heic", HEIF}, } @@ -29,8 +29,9 @@ func TestDeterminateImageType(t *testing.T) { defer img.Close() if VipsIsTypeSupported(file.expected) { - if DetermineImageType(buf) != file.expected { - t.Fatalf("Image type is not valid: %s != %s", file.name, ImageTypes[file.expected]) + value := DetermineImageType(buf) + if value != file.expected { + t.Fatalf("Image type is not valid: %s != %s, got: %s", file.name, ImageTypes[file.expected], ImageTypes[value]) } } } @@ -47,7 +48,7 @@ func TestDeterminateImageTypeName(t *testing.T) { {"test.gif", "gif"}, {"test.pdf", "pdf"}, {"test.svg", "svg"}, - {"test.jp2", "magick"}, + // {"test.jp2", "magick"}, {"test.heic", "heif"}, } @@ -56,8 +57,9 @@ func TestDeterminateImageTypeName(t *testing.T) { buf, _ := ioutil.ReadAll(img) defer img.Close() - if DetermineImageTypeName(buf) != file.expected { - t.Fatalf("Image type is not valid: %s != %s", file.name, file.expected) + value := DetermineImageTypeName(buf) + if value != file.expected { + t.Fatalf("Image type is not valid: %s != %s, got: %s", file.name, file.expected, value) } } }