Skip to content

Commit

Permalink
Minor fixes based on PR #242, adds macos-12 golden snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbyttow committed Jan 9, 2022
1 parent f626513 commit b623d9a
Show file tree
Hide file tree
Showing 79 changed files with 35 additions and 36 deletions.
3 changes: 1 addition & 2 deletions examples/logging/example_logging_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ func main() {
checkError(err)
myLogger("loggingExample", vips.LogLevelInfo, fmt.Sprintf("Before: %v x %v", image1.Height(), image1.Width()))

ep := vips.NewDefaultJPEGExportParams()
image1bytes, _, err := image1.Export(ep)
image1bytes, _, err := image1.ExportJpeg(nil)
checkError(err)
err = ioutil.WriteFile("output.jpg", image1bytes, 0644)
checkError(err)
Expand Down
7 changes: 3 additions & 4 deletions examples/tiff/example_tiff_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,9 @@ func main() {
checkError(err)
fmt.Println(inputImage.Height(), inputImage.Width())

ep := vips.NewDefaultExportParams()
ep.Format = vips.ImageTypeTIFF
ep.Quality = 100
imageBytes, _, err := inputImage.Export(ep)
exportParams := vips.NewTiffExportParams()
exportParams.Quality = 100
imageBytes, _, err := inputImage.ExportTiff(exportParams)
err = ioutil.WriteFile("examples/tiff/output-govips.tiff", imageBytes, 0644)
checkError(err)
}
Binary file added resources/bmp.Decode_BMP-macos-12.golden.png
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 not shown.
Binary file not shown.
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.
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.
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.
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.
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.
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.
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 resources/jpg-24bit.Add-macos-12.golden.jpeg
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 resources/jpg-24bit.Black-macos-12.golden.jpeg
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 resources/jpg-24bit.DrawRect-macos-12.golden.jpeg
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 resources/jpg-24bit.Embed-macos-12.golden.jpeg
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 resources/jpg-24bit.Flip-macos-12.golden.jpeg
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 resources/jpg-24bit.Invert-macos-12.golden.jpeg
Binary file added resources/jpg-24bit.Multiply-macos-12.golden.jpeg
Binary file added resources/jpg-24bit.Zoom-macos-12.golden.jpeg
Binary file not shown.
Binary file not shown.
Binary file added resources/png-24bit.Rank-macos-12.golden.png
Binary file added resources/png-8bit.Decode_PNG-macos-12.golden.png
Binary file added resources/tif.Tiff-macos-12.golden.tiff
Binary file not shown.
Binary file added resources/with_alpha.ExtractBand-macos-12.golden.png
Binary file added resources/with_alpha.Flatten-macos-12.golden.png
14 changes: 7 additions & 7 deletions vips/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -454,8 +454,8 @@ func (r *ImageRef) Copy() (*ImageRef, error) {
// XYZ creates a two-band uint32 image where the elements in the first band have the value of their x coordinate
// and elements in the second band have their y coordinate.
func XYZ(width, height int) (*ImageRef, error) {
image, err := vipsXYZ(width, height)
return &ImageRef{image: image}, err
vipsImage, err := vipsXYZ(width, height)
return &ImageRef{image: vipsImage}, err
}

// Identity creates an identity lookup table, which will leave an image unchanged when applied with Maplut.
Expand All @@ -467,18 +467,18 @@ func Identity(ushort bool) (*ImageRef, error) {

// Black creates a new black image of the specified size
func Black(width, height int) (*ImageRef, error) {
image, err := vipsBlack(width, height)
return &ImageRef{image: image}, err
vipsImage, err := vipsBlack(width, height)
return &ImageRef{image: vipsImage}, err
}

func newImageRef(vipsImage *C.VipsImage, format ImageType, buf []byte) *ImageRef {
image := &ImageRef{
imageRef := &ImageRef{
image: vipsImage,
format: format,
buf: buf,
}
runtime.SetFinalizer(image, finalizeImage)
return image
runtime.SetFinalizer(imageRef, finalizeImage)
return imageRef
}

func finalizeImage(ref *ImageRef) {
Expand Down
47 changes: 24 additions & 23 deletions vips/image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func TestImageRef_WebP(t *testing.T) {
require.NoError(t, err)
require.NotNil(t, img)

_, _, err = img.Export(nil)
_, _, err = img.ExportWebp(nil)
assert.NoError(t, err)
}

Expand All @@ -46,9 +46,9 @@ func TestImageRef_WebP__ReducedEffort(t *testing.T) {
require.NoError(t, err)
require.NotNil(t, img)

params := NewDefaultWEBPExportParams()
params.Effort = 2
_, _, err = img.Export(params)
params := NewWebpExportParams()
params.ReductionEffort = 2
_, _, err = img.ExportWebp(params)
assert.NoError(t, err)
}

Expand Down Expand Up @@ -81,9 +81,9 @@ func TestImageRef_PNG(t *testing.T) {
require.NotNil(t, img)

// check random access by encoding twice
_, _, err = img.Export(nil)
_, _, err = img.ExportNative()
assert.NoError(t, err)
_, _, err = img.Export(nil)
_, _, err = img.ExportNative()
assert.NoError(t, err)
}

Expand All @@ -97,7 +97,7 @@ func TestImageRef_HEIF(t *testing.T) {
require.NoError(t, err)
require.NotNil(t, img)

_, metadata, err := img.Export(nil)
_, metadata, err := img.ExportNative()
assert.NoError(t, err)
assert.Equal(t, ImageTypeHEIF, metadata.Format)
}
Expand All @@ -112,7 +112,7 @@ func TestImageRef_HEIF_MIF1(t *testing.T) {
require.NoError(t, err)
require.NotNil(t, img)

_, metadata, err := img.Export(nil)
_, metadata, err := img.ExportNative()
assert.NoError(t, err)
assert.Equal(t, ImageTypeHEIF, metadata.Format)
}
Expand All @@ -127,12 +127,12 @@ func TestImageRef_HEIF_ftypmsf1(t *testing.T) {
require.NoError(t, err)
require.NotNil(t, img)

_, metadata, err := img.Export(nil)
_, metadata, err := img.ExportNative()
assert.NoError(t, err)
assert.Equal(t, ImageTypeHEIF, metadata.Format)
}

func TestImageRef_BMP(t *testing.T) {
func TestImageRef_BMP__ImplicitConversionToPNG(t *testing.T) {
Startup(nil)

raw, err := ioutil.ReadFile(resources + "bmp.bmp")
Expand All @@ -142,7 +142,7 @@ func TestImageRef_BMP(t *testing.T) {
require.NoError(t, err)
require.NotNil(t, img)

exported, metadata, err := img.Export(nil)
exported, metadata, err := img.ExportNative()
assert.NoError(t, err)
assert.Equal(t, ImageTypePNG, metadata.Format)
assert.NotNil(t, exported)
Expand Down Expand Up @@ -248,7 +248,7 @@ func TestImageRef_AddAlpha(t *testing.T) {
assert.NoError(t, err)
assert.True(t, img.HasAlpha(), "has alpha")

_, _, err = img.Export(nil)
_, _, err = img.ExportNative()
assert.NoError(t, err)
}

Expand All @@ -263,7 +263,7 @@ func TestImageRef_AddAlpha__Idempotent(t *testing.T) {
assert.NoError(t, err)

assert.True(t, img.HasAlpha(), "has alpha")
_, _, err = img.Export(nil)
_, _, err = img.ExportNative()
assert.NoError(t, err)
}

Expand Down Expand Up @@ -630,19 +630,20 @@ func TestImageRef_CompositeMulti(t *testing.T) {
image, err := NewImageFromFile(resources + "png-24bit.png")
require.NoError(t, err)

images := []*ImageComposite{}
for i, uri := range []string{"png-8bit+alpha.png", "png-24bit+alpha.png"} {
sources := []string{"png-8bit+alpha.png", "png-24bit+alpha.png"}
images := make([]*ImageComposite, len(sources))
for i, uri := range sources {
image, err := NewImageFromFile(resources + uri)
require.NoError(t, err)

//add offset test
images = append(images, &ImageComposite{image, BlendModeOver, (i + 1) * 20, (i + 2) * 20})
images[i] = &ImageComposite{image, BlendModeOver, (i + 1) * 20, (i + 2) * 20}
}

err = image.CompositeMulti(images)
require.NoError(t, err)

_, _, err = image.Export(nil)
_, _, err = image.ExportNative()
require.NoError(t, err)
}

Expand Down Expand Up @@ -670,7 +671,7 @@ func BenchmarkExportImage(b *testing.B) {
b.SetParallelism(100)
b.ResetTimer()
for n := 0; n < b.N; n++ {
_, _, err = img.Export(NewDefaultJPEGExportParams())
_, _, err = img.ExportJpeg(nil)
require.NoError(b, err)
}
b.ReportAllocs()
Expand Down Expand Up @@ -754,13 +755,13 @@ func TestResOffset(t *testing.T) {

x := image.ResX()
y := image.ResY()
offx := image.OffsetX()
offy := image.OffsetY()
offsetX := image.OffsetX()
offsetY := image.OffsetY()

assert.Equal(t, x, float64(2.835))
assert.Equal(t, y, float64(2.835))
assert.Equal(t, offx, 0)
assert.Equal(t, offy, 0)
assert.Equal(t, offsetX, 0)
assert.Equal(t, offsetY, 0)
}

func TestToBytes(t *testing.T) {
Expand Down Expand Up @@ -952,7 +953,7 @@ func TestImageRef_AVIF(t *testing.T) {
require.NoError(t, err)
require.NotNil(t, img)

_, metadata, err := img.Export(nil)
_, metadata, err := img.ExportNative()
assert.NoError(t, err)
assert.Equal(t, ImageTypeAVIF, metadata.Format)
}
Expand Down

0 comments on commit b623d9a

Please sign in to comment.