test region_shrink

just sets the option, does not verify accuracy :(
This commit is contained in:
John Cupitt 2018-07-07 17:07:35 +01:00
parent 92ff5be4b8
commit 2695916afb
2 changed files with 121 additions and 124 deletions

108
README.md
View File

@ -41,7 +41,7 @@ https://github.com/jcupitt/libvips/releases
Untar, then in the libvips directory you should just be able to do:
$ ./configure
$ ./configure
Check the summary at the end of `configure` carefully. libvips must have
`build-essential`, `pkg-config`, `glib2.0-dev`, `libexpat1-dev`.
@ -53,8 +53,8 @@ of the things that libvips can be configured to use.
Once `configure` is looking OK, compile and install with the usual:
$ make
$ sudo make install
$ make
$ sudo make install
By default this will install files to `/usr/local`.
@ -66,11 +66,15 @@ Windows](https://github.com/jcupitt/libvips/wiki/Build-for-Windows) and
Do a basic test of your build with:
$ make check
$ make check
Run the libvips test suite with:
$ pytest
$ pytest
Run a specific test with:
$ pytest test/test-suite/test_foreign.py -k test_tiff
YOu will need to install a variety of Python packages for this, including
pyvips, the libvips Python binding.
@ -79,78 +83,78 @@ pyvips, the libvips Python binding.
Checkout the latest sources with:
$ git clone git://github.com/jcupitt/libvips.git
$ git clone git://github.com/jcupitt/libvips.git
Building from git needs more packages, you'll need at least `swig`, `gtk-doc`
and `gobject-introspection`, see the dependencies section below. For example:
$ brew install gtk-doc swig
$ brew install gtk-doc swig
Then build the build system with:
$ ./autogen.sh
$ ./autogen.sh
Debug build:
$ CFLAGS="-g -Wall" CXXFLAGS="-g -Wall" \
./configure --prefix=/home/john/vips --enable-debug
$ make
$ make install
$ CFLAGS="-g -Wall" CXXFLAGS="-g -Wall" \
./configure --prefix=/home/john/vips --enable-debug
$ make
$ make install
Leak check:
$ export G_DEBUG=gc-friendly
$ valgrind --suppressions=libvips.supp \
--leak-check=yes \
vips ... > vips-vg.log 2>&1
$ export G_DEBUG=gc-friendly
$ valgrind --suppressions=libvips.supp \
--leak-check=yes \
vips ... > vips-vg.log 2>&1
Memory error debug:
$ valgrind --vgdb=yes --vgdb-error=0 vips ...
$ valgrind --vgdb=yes --vgdb-error=0 vips ...
valgrind threading check:
$ valgrind --tool=helgrind vips ... > vips-vg.log 2>&1
$ valgrind --tool=helgrind vips ... > vips-vg.log 2>&1
Clang build:
$ CC=clang CXX=clang++ ./configure --prefix=/home/john/vips
$ CC=clang CXX=clang++ ./configure --prefix=/home/john/vips
Clang static analysis:
$ scan-build ./configure --disable-introspection --disable-debug
$ scan-build -o scan -v make
$ scan-view scan/2013-11-22-2
$ scan-build ./configure --disable-introspection --disable-debug
$ scan-build -o scan -v make
$ scan-view scan/2013-11-22-2
Clang dynamic analysis:
$ FLAGS="-O1 -g -fsanitize=address"
$ FLAGS="$FLAGS -fno-omit-frame-pointer -fno-optimize-sibling-calls"
$ CC=clang CXX=clang++ LD=clang \
CFLAGS="$FLAGS" CXXFLAGS="$FLAGS" LDFLAGS=-fsanitize=address \
./configure --prefix=/home/john/vips
$ FLAGS="-O1 -g -fsanitize=address"
$ FLAGS="$FLAGS -fno-omit-frame-pointer -fno-optimize-sibling-calls"
$ CC=clang CXX=clang++ LD=clang \
CFLAGS="$FLAGS" CXXFLAGS="$FLAGS" LDFLAGS=-fsanitize=address \
./configure --prefix=/home/john/vips
$ FLAGS="-O1 -g -fsanitize=thread"
$ FLAGS="$FLAGS -fPIC"
$ FLAGS="$FLAGS -fno-omit-frame-pointer -fno-optimize-sibling-calls"
$ CC=clang CXX=clang++ LD=clang \
CFLAGS="$FLAGS" CXXFLAGS="$FLAGS" \
LDFLAGS="-fsanitize=thread -fPIC" \
./configure --prefix=/home/john/vips \
--without-magick \
--disable-introspection
$ G_DEBUG=gc-friendly vips copy ~/pics/k2.jpg x.jpg >& log
$ FLAGS="-O1 -g -fsanitize=thread"
$ FLAGS="$FLAGS -fPIC"
$ FLAGS="$FLAGS -fno-omit-frame-pointer -fno-optimize-sibling-calls"
$ CC=clang CXX=clang++ LD=clang \
CFLAGS="$FLAGS" CXXFLAGS="$FLAGS" \
LDFLAGS="-fsanitize=thread -fPIC" \
./configure --prefix=/home/john/vips \
--without-magick \
--disable-introspection
$ G_DEBUG=gc-friendly vips copy ~/pics/k2.jpg x.jpg >& log
Build with the GCC auto-vectorizer and diagnostics (or just -O3):
$ FLAGS="-O2 -march=native -ffast-math"
$ FLAGS="$FLAGS -ftree-vectorize -fdump-tree-vect-details"
$ CFLAGS="$FLAGS" CXXFLAGS="$FLAGS" \
./configure --prefix=/home/john/vips
$ FLAGS="-O2 -march=native -ffast-math"
$ FLAGS="$FLAGS -ftree-vectorize -fdump-tree-vect-details"
$ CFLAGS="$FLAGS" CXXFLAGS="$FLAGS" \
./configure --prefix=/home/john/vips
Static analysis with:
$ cppcheck --force --enable=style . &> cppcheck.log
$ cppcheck --force --enable=style . &> cppcheck.log
# Dependencies
@ -168,19 +172,19 @@ them in the default path and in `$prefix`. If you have installed your own
versions of these libraries in a different location, libvips will not see
them. Use switches to libvips configure like:
./configure --prefix=/Users/john/vips \
--with-giflib-includes=/opt/local/include \
--with-giflib-libraries=/opt/local/lib \
--with-tiff-includes=/opt/local/include \
--with-tiff-libraries=/opt/local/lib \
--with-jpeg-includes=/opt/local/include \
--with-jpeg-libraries=/opt/local/lib
./configure --prefix=/Users/john/vips \
--with-giflib-includes=/opt/local/include \
--with-giflib-libraries=/opt/local/lib \
--with-tiff-includes=/opt/local/include \
--with-tiff-libraries=/opt/local/lib \
--with-jpeg-includes=/opt/local/include \
--with-jpeg-libraries=/opt/local/lib
or perhaps:
CFLAGS="-g -Wall -I/opt/local/include -L/opt/local/lib" \
CXXFLAGS="-g -Wall -I/opt/local/include -L/opt/local/lib" \
./configure --without-python --prefix=/Users/john/vips
CFLAGS="-g -Wall -I/opt/local/include -L/opt/local/lib" \
CXXFLAGS="-g -Wall -I/opt/local/include -L/opt/local/lib" \
./configure --without-python --prefix=/Users/john/vips
to get libvips to see your builds.

View File

@ -320,54 +320,58 @@ class TestForeign:
assert x1.height == x2.width
# OME support in 8.5
if pyvips.at_least_libvips(8, 5):
x = pyvips.Image.new_from_file(OME_FILE)
assert x.width == 439
assert x.height == 167
page_height = x.height
x = pyvips.Image.new_from_file(OME_FILE)
assert x.width == 439
assert x.height == 167
page_height = x.height
x = pyvips.Image.new_from_file(OME_FILE, n=-1)
assert x.width == 439
assert x.height == page_height * 15
x = pyvips.Image.new_from_file(OME_FILE, n=-1)
assert x.width == 439
assert x.height == page_height * 15
x = pyvips.Image.new_from_file(OME_FILE, page=1, n=-1)
assert x.width == 439
assert x.height == page_height * 14
x = pyvips.Image.new_from_file(OME_FILE, page=1, n=-1)
assert x.width == 439
assert x.height == page_height * 14
x = pyvips.Image.new_from_file(OME_FILE, page=1, n=2)
assert x.width == 439
assert x.height == page_height * 2
x = pyvips.Image.new_from_file(OME_FILE, page=1, n=2)
assert x.width == 439
assert x.height == page_height * 2
x = pyvips.Image.new_from_file(OME_FILE, n=-1)
assert x(0, 166)[0] == 96
assert x(0, 167)[0] == 0
assert x(0, 168)[0] == 1
x = pyvips.Image.new_from_file(OME_FILE, n=-1)
assert x(0, 166)[0] == 96
assert x(0, 167)[0] == 0
assert x(0, 168)[0] == 1
filename = temp_filename(self.tempdir, '.tif')
x.write_to_file(filename)
filename = temp_filename(self.tempdir, '.tif')
x.write_to_file(filename)
x = pyvips.Image.new_from_file(filename, n=-1)
assert x.width == 439
assert x.height == page_height * 15
assert x(0, 166)[0] == 96
assert x(0, 167)[0] == 0
assert x(0, 168)[0] == 1
x = pyvips.Image.new_from_file(filename, n=-1)
assert x.width == 439
assert x.height == page_height * 15
assert x(0, 166)[0] == 96
assert x(0, 167)[0] == 0
assert x(0, 168)[0] == 1
# pyr save to buffer added in 8.6
if pyvips.at_least_libvips(8, 6):
x = pyvips.Image.new_from_file(TIF_FILE)
buf = x.tiffsave_buffer(tile=True, pyramid=True)
filename = temp_filename(self.tempdir, '.tif')
x.tiffsave(filename, tile=True, pyramid=True)
with open(filename, 'rb') as f:
buf2 = f.read()
assert len(buf) == len(buf2)
x = pyvips.Image.new_from_file(TIF_FILE)
buf = x.tiffsave_buffer(tile=True, pyramid=True)
filename = temp_filename(self.tempdir, '.tif')
x.tiffsave(filename, tile=True, pyramid=True)
with open(filename, 'rb') as f:
buf2 = f.read()
assert len(buf) == len(buf2)
a = pyvips.Image.new_from_buffer(buf, "", page=2)
b = pyvips.Image.new_from_buffer(buf2, "", page=2)
assert a.width == b.width
assert a.height == b.height
assert a.avg() == b.avg()
a = pyvips.Image.new_from_buffer(buf, "", page=2)
b = pyvips.Image.new_from_buffer(buf2, "", page=2)
assert a.width == b.width
assert a.height == b.height
assert a.avg() == b.avg()
# region-shrink added in 8.7
x = pyvips.Image.new_from_file(TIF_FILE)
buf = x.tiffsave_buffer(tile=True, pyramid=True, region_shrink="mean")
buf = x.tiffsave_buffer(tile=True, pyramid=True, region_shrink="mode")
buf = x.tiffsave_buffer(tile=True, pyramid=True, region_shrink="median")
@skip_if_no("magickload")
def test_magickload(self):
@ -637,7 +641,7 @@ class TestForeign:
self.save_buffer_tempfile("radsave_buffer", ".hdr",
self.rad, max_diff=0)
@skip_if_no("dzsaveload")
@skip_if_no("dzsave")
def test_dzsave(self):
# dzsave is hard to test, there are so many options
# test each option separately and hope they all function together
@ -706,16 +710,14 @@ class TestForeign:
# with 511x511, it'll fit exactly into 2x2 -- we we actually generate
# 3x3, since we output the overlaps
# 8.6 revised the rules on overlaps, so don't test earlier than that
if pyvips.base.at_least_libvips(8, 6):
filename = temp_filename(self.tempdir, '')
self.colour.crop(0, 0, 511, 511).dzsave(filename, layout="google",
overlap=1, depth="one")
filename = temp_filename(self.tempdir, '')
self.colour.crop(0, 0, 511, 511).dzsave(filename, layout="google",
overlap=1, depth="one")
x = pyvips.Image.new_from_file(filename + "/0/2/2.jpg")
assert x.width == 256
assert x.height == 256
assert not os.path.exists(filename + "/0/3/3.jpg")
x = pyvips.Image.new_from_file(filename + "/0/2/2.jpg")
assert x.width == 256
assert x.height == 256
assert not os.path.exists(filename + "/0/3/3.jpg")
# default zoomify layout
filename = temp_filename(self.tempdir, '')
@ -730,10 +732,6 @@ class TestForeign:
# test zip output
filename = temp_filename(self.tempdir, '.zip')
self.colour.dzsave(filename)
# before 8.5.8, you needed a gc on pypy to flush small zip output to
# disc
if not pyvips.base.at_least_libvips(8, 6):
gc.collect()
assert os.path.exists(filename)
assert not os.path.exists(filename + "_files")
assert not os.path.exists(filename + ".dzi")
@ -741,10 +739,6 @@ class TestForeign:
# test compressed zip output
filename2 = temp_filename(self.tempdir, '.zip')
self.colour.dzsave(filename2, compression=-1)
# before 8.5.8, you needed a gc on pypy to flush small zip output to
# disc
if not pyvips.base.at_least_libvips(8, 6):
gc.collect()
assert os.path.exists(filename2)
assert os.path.getsize(filename2) < os.path.getsize(filename)
@ -771,24 +765,23 @@ class TestForeign:
assert y.height == 513
# test save to memory buffer
if have("dzsave_buffer"):
filename = temp_filename(self.tempdir, '.zip')
base = os.path.basename(filename)
root, ext = os.path.splitext(base)
filename = temp_filename(self.tempdir, '.zip')
base = os.path.basename(filename)
root, ext = os.path.splitext(base)
self.colour.dzsave(filename)
# before 8.5.8, you needed a gc on pypy to flush small zip
# output to disc
if not pyvips.base.at_least_libvips(8, 6):
gc.collect()
with open(filename, 'rb') as f:
buf1 = f.read()
buf2 = self.colour.dzsave_buffer(basename=root)
assert len(buf1) == len(buf2)
self.colour.dzsave(filename)
with open(filename, 'rb') as f:
buf1 = f.read()
buf2 = self.colour.dzsave_buffer(basename=root)
assert len(buf1) == len(buf2)
# we can't test the bytes are exactly equal -- the timestamps will
# be different
# we can't test the bytes are exactly equal -- the timestamps will
# be different
# added in 8.7
buf = self.colour.dzsave_buffer(region_shrink="mean")
buf = self.colour.dzsave_buffer(region_shrink="mode")
buf = self.colour.dzsave_buffer(region_shrink="median")
if __name__ == '__main__':
pytest.main()