From 8f1aaeaa7d2b490c29b684d159e6163facf52980 Mon Sep 17 00:00:00 2001 From: Alistair Thomas Date: Sun, 17 Sep 2017 14:44:59 +0100 Subject: [PATCH 1/7] Remove additional install of pkg-config, automake and giflib from macOS CI The Travis build for macOS is failing because brew errors out when it finds pkg-config, automake and giflib have already been installed. --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index aebe3d18..5bc2862d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -71,7 +71,7 @@ matrix: before_install: - brew tap homebrew/science - brew update - - brew install ccache pkg-config automake + - brew install ccache - brew install --ignore-dependencies gtk-doc - brew install gobject-introspection @@ -81,5 +81,5 @@ matrix: cfitsio libmatio orc little-cms2 poppler pango libgsf openslide - librsvg giflib openexr + librsvg openexr - brew install pygobject3 From fa4cc1a0aca987b32854d8d0f7749c65db2e77a1 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Sun, 17 Sep 2017 17:13:11 +0100 Subject: [PATCH 2/7] turn osx back on for travis and remove the py stuff: this is no longer used for the test suite --- .travis.yml | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index aebe3d18..0185c85b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,17 +9,13 @@ before_script: script: - make -Ctest -j$JOBS -s V=0 VERBOSE=1 check -# allow osx to fail since brew so often falls over matrix: fast_finish: true - allow_failures: - - os: osx include: - os: linux sudo: required dist: precise env: - - PYTHON=/usr/bin/python - JPEG=/usr - JOBS=`nproc` - LIBTOOLFLAGS=--quiet @@ -28,7 +24,6 @@ matrix: - sudo apt-get update -qq - sudo apt-get install -y automake gtk-doc-tools - gobject-introspection libfftw3-dev libjpeg-turbo8-dev libpng12-dev libwebp-dev libtiff4-dev libexpat1-dev swig libmagick++-dev bc @@ -36,13 +31,11 @@ matrix: liborc-0.4-dev liblcms2-dev libpoppler-glib-dev librsvg2-dev libgif-dev libpango1.0-dev - python-dev - os: linux sudo: required dist: trusty env: - - PYTHON=/usr/bin/python - JPEG=/usr - JOBS=`nproc` cache: ccache @@ -50,7 +43,6 @@ matrix: - sudo apt-get update -qq - sudo apt-get install -y automake gtk-doc-tools - gobject-introspection libfftw3-dev libjpeg-turbo8-dev libpng12-dev libwebp-dev libtiff4-dev libexpat1-dev swig libmagick++-dev bc @@ -58,12 +50,10 @@ matrix: liborc-0.4-dev liblcms2-dev libpoppler-glib-dev librsvg2-dev libgif-dev libpango1.0-dev libgsf-1-dev libopenslide-dev - python-dev python-gi-dev libgirepository1.0-dev - os: osx osx_image: xcode7.3 env: - - PYTHON=/usr/local/bin/python - JPEG=/usr/local/opt/mozjpeg - JOBS="`sysctl -n hw.ncpu`" - PATH="/usr/local/opt/ccache/libexec:$PATH" @@ -74,7 +64,6 @@ matrix: - brew install ccache pkg-config automake - brew install --ignore-dependencies gtk-doc - brew install - gobject-introspection fftw mozjpeg libexif libpng webp swig imagemagick @@ -82,4 +71,3 @@ matrix: orc little-cms2 poppler pango libgsf openslide librsvg giflib openexr - - brew install pygobject3 From 6aca3bae53cc74d85c87137bf15d181a515eda19 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Sun, 17 Sep 2017 17:43:50 +0100 Subject: [PATCH 3/7] re-add goi it's a hard dep --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 78f1af19..7e99cecd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,6 +24,7 @@ matrix: - sudo apt-get update -qq - sudo apt-get install -y automake gtk-doc-tools + gobject-introspection libfftw3-dev libjpeg-turbo8-dev libpng12-dev libwebp-dev libtiff4-dev libexpat1-dev swig libmagick++-dev bc @@ -43,6 +44,7 @@ matrix: - sudo apt-get update -qq - sudo apt-get install -y automake gtk-doc-tools + gobject-introspection libfftw3-dev libjpeg-turbo8-dev libpng12-dev libwebp-dev libtiff4-dev libexpat1-dev swig libmagick++-dev bc @@ -64,6 +66,7 @@ matrix: - brew install ccache - brew install --ignore-dependencies gtk-doc - brew install + gobject-introspection fftw mozjpeg libexif libpng webp swig imagemagick From d289b61fdca0ffb76049115753148d49f191fa48 Mon Sep 17 00:00:00 2001 From: Alistair Thomas Date: Sun, 17 Sep 2017 22:51:14 +0100 Subject: [PATCH 4/7] Improve the gobject introspection annotations for Image.avg () --- libvips/arithmetic/avg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libvips/arithmetic/avg.c b/libvips/arithmetic/avg.c index 8946f72e..a7d18fc5 100644 --- a/libvips/arithmetic/avg.c +++ b/libvips/arithmetic/avg.c @@ -225,9 +225,9 @@ vips_avg_init( VipsAvg *avg ) /** - * vips_avg: + * vips_avg: (method) * @in: input #VipsImage - * @out: output pixel average + * @out: (out): output pixel average * @...: %NULL-terminated list of optional named arguments * * This operation finds the average value in an image. It operates on all From cfe907deb36d70914b55a7961784bf51da2bda44 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Mon, 18 Sep 2017 12:44:19 +0100 Subject: [PATCH 5/7] missing bandor in find_trim it cropped too aggressively on images with highly-coloured edges see https://github.com/jcupitt/libvips/issues/670 --- libvips/arithmetic/find_trim.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/libvips/arithmetic/find_trim.c b/libvips/arithmetic/find_trim.c index 66a030be..17186f16 100644 --- a/libvips/arithmetic/find_trim.c +++ b/libvips/arithmetic/find_trim.c @@ -2,6 +2,8 @@ * * 26/7/17 * - from a ruby example + * 18/9/17 kleisauke + * - missing bandor */ /* @@ -116,39 +118,40 @@ vips_find_trim_build( VipsObject *object ) if( vips_median( t[0], &t[1], 3, NULL ) || vips_linear( t[1], &t[2], ones, neg_bg, n, NULL ) || vips_abs( t[2], &t[3], NULL ) || - vips_more_const1( t[3], &t[4], find_trim->threshold, NULL ) ) + vips_more_const1( t[3], &t[4], find_trim->threshold, NULL ) || + vips_bandor( t[4], &t[5], NULL ) ) return( -1 ); - /* t[5] == column sums, t[6] == row sums. + /* t[6] == column sums, t[7] == row sums. */ - if( vips_project( t[4], &t[5], &t[6], NULL ) ) + if( vips_project( t[5], &t[6], &t[7], NULL ) ) return( -1 ); /* t[8] == search column sums in from left. */ - if( vips_profile( t[5], &t[7], &t[8], NULL ) || - vips_avg( t[8], &left, NULL ) ) + if( vips_profile( t[6], &t[8], &t[9], NULL ) || + vips_avg( t[9], &left, NULL ) ) return( -1 ); - if( vips_flip( t[5], &t[9], VIPS_DIRECTION_HORIZONTAL, NULL ) || - vips_profile( t[9], &t[10], &t[11], NULL ) || - vips_avg( t[11], &right, NULL ) ) + if( vips_flip( t[6], &t[10], VIPS_DIRECTION_HORIZONTAL, NULL ) || + vips_profile( t[10], &t[11], &t[12], NULL ) || + vips_avg( t[12], &right, NULL ) ) return( -1 ); /* t[8] == search column sums in from left. */ - if( vips_profile( t[6], &t[12], &t[13], NULL ) || - vips_avg( t[12], &top, NULL ) ) + if( vips_profile( t[7], &t[13], &t[14], NULL ) || + vips_avg( t[13], &top, NULL ) ) return( -1 ); - if( vips_flip( t[6], &t[14], VIPS_DIRECTION_VERTICAL, NULL ) || - vips_profile( t[14], &t[15], &t[16], NULL ) || - vips_avg( t[15], &bottom, NULL ) ) + if( vips_flip( t[7], &t[15], VIPS_DIRECTION_VERTICAL, NULL ) || + vips_profile( t[15], &t[16], &t[17], NULL ) || + vips_avg( t[16], &bottom, NULL ) ) return( -1 ); g_object_set( find_trim, "left", (int) left, "top", (int) top, - "width", (int) VIPS_MAX( 0, (t[5]->Xsize - right) - left ), - "height", (int) VIPS_MAX( 0, (t[6]->Ysize - bottom) - top ), + "width", (int) VIPS_MAX( 0, (t[6]->Xsize - right) - left ), + "height", (int) VIPS_MAX( 0, (t[7]->Ysize - bottom) - top ), NULL ); return( 0 ); From 0d93f9f9dd1996a74e318b90765c8f061ec8746c Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Mon, 18 Sep 2017 12:56:35 +0100 Subject: [PATCH 6/7] note flatten before getpoint for find_trim add note on flatten before getpoint see https://github.com/jcupitt/libvips/issues/670 --- libvips/arithmetic/find_trim.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libvips/arithmetic/find_trim.c b/libvips/arithmetic/find_trim.c index 17186f16..0ca730b8 100644 --- a/libvips/arithmetic/find_trim.c +++ b/libvips/arithmetic/find_trim.c @@ -256,7 +256,8 @@ vips_find_trim_init( VipsFindTrim *find_trim ) * and @height == 0. * * @background defaults to 255, or 65535 for 16-bit images. Set another value, - * or use vips_getpoint() to pick a value from an edge. + * or use vips_getpoint() to pick a value from an edge. You'll need to flatten + * before vips_getpoint() to get a correct background value. * * @threshold defaults to 10. * From 0193e23c648cb89d453fe90e5c01f9c5fd0e34d4 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Mon, 18 Sep 2017 14:48:15 +0100 Subject: [PATCH 7/7] only flatten in find_trim if there is an alpha oops, flatten always flattens, it doesn't check for alpha first see https://github.com/jcupitt/libvips/issues/670 --- libvips/arithmetic/find_trim.c | 21 ++++++++++++++------- libvips/iofuncs/cache.c | 2 ++ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/libvips/arithmetic/find_trim.c b/libvips/arithmetic/find_trim.c index 0ca730b8..1eada0b0 100644 --- a/libvips/arithmetic/find_trim.c +++ b/libvips/arithmetic/find_trim.c @@ -4,6 +4,7 @@ * - from a ruby example * 18/9/17 kleisauke * - missing bandor + * - only flatten if there is an alpha */ /* @@ -71,6 +72,7 @@ vips_find_trim_build( VipsObject *object ) VipsFindTrim *find_trim = (VipsFindTrim *) object; VipsImage **t = (VipsImage **) vips_object_local_array( object, 20 ); + VipsImage *in; double *background; int n; double *neg_bg; @@ -95,12 +97,16 @@ vips_find_trim_build( VipsObject *object ) vips_array_double_newv( 1, 65535.0 ); } - /* Flatten out any alpha. + /* Flatten out alpha, if any. */ - if( vips_flatten( find_trim->in, &t[0], - "background", find_trim->background, - NULL ) ) - return( -1 ); + in = find_trim->in; + if( vips_image_hasalpha( in ) ) { + if( vips_flatten( in, &t[0], + "background", find_trim->background, + NULL ) ) + return( -1 ); + in = t[0]; + } /* We want to subtract the bg. */ @@ -115,16 +121,17 @@ vips_find_trim_build( VipsObject *object ) /* Smooth, find difference from bg, abs, threshold. */ - if( vips_median( t[0], &t[1], 3, NULL ) || + if( vips_median( in, &t[1], 3, NULL ) || vips_linear( t[1], &t[2], ones, neg_bg, n, NULL ) || vips_abs( t[2], &t[3], NULL ) || vips_more_const1( t[3], &t[4], find_trim->threshold, NULL ) || vips_bandor( t[4], &t[5], NULL ) ) return( -1 ); + in = t[5]; /* t[6] == column sums, t[7] == row sums. */ - if( vips_project( t[5], &t[6], &t[7], NULL ) ) + if( vips_project( in, &t[6], &t[7], NULL ) ) return( -1 ); /* t[8] == search column sums in from left. diff --git a/libvips/iofuncs/cache.c b/libvips/iofuncs/cache.c index 9129b152..a3d70477 100644 --- a/libvips/iofuncs/cache.c +++ b/libvips/iofuncs/cache.c @@ -453,6 +453,8 @@ vips__cache_once_init( void ) vips_cache_table = g_hash_table_new( (GHashFunc) vips_operation_hash, (GEqualFunc) vips_operation_equal ); + + return( NULL ); } void