govips
govips copied to clipboard
implement vips_image_new_from_file
This enables creating new image object directly from file path, using vips_image_new_from_file:
Below is the go bench of NewImageFromFile
against the master branch. The memory difference B/op
is very noticeable. The speed maybe slightly slower, presumably due to disk seek (instead of all loaded in memory).
(base) ➜ govips git:(master) go test -bench=NewImageFromFile -benchtime=30s -benchmem ./examples/thumbnail
goos: darwin
goarch: amd64
pkg: github.com/davidbyttow/govips/v2/examples/thumbnail
cpu: Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
BenchmarkNewImageFromFile-4 91 388221588 ns/op 2600845 B/op 234 allocs/op
PASS
ok github.com/davidbyttow/govips/v2/examples/thumbnail 36.420s
(base) ➜ govips git:(vips_new_image) go test -bench=NewImageFromFile -benchtime=30s -benchmem ./examples/thumbnail
goos: darwin
goarch: amd64
pkg: github.com/davidbyttow/govips/v2/examples/thumbnail
cpu: Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
BenchmarkNewImageFromFile-4 90 395057470 ns/op 261382 B/op 201 allocs/op
PASS
ok github.com/davidbyttow/govips/v2/examples/thumbnail 36.167s
However this relies on libvips's VIPS_META_LOADER to determine image type, instead of govips's DetermineImageType
, which potentially introduces different behaviour for edge cases.
Tests passing under Linux, but TestImage_DrawRectRGBA
seems to be failing under MacOS I am not sure why.
#289