From c2ff2c6e5d4bc6de16916c042cce91faa05277a0 Mon Sep 17 00:00:00 2001 From: Benjamin Gilbert Date: Sun, 27 Oct 2013 22:01:47 -0400 Subject: [PATCH 1/4] fix stray uses of "layer" in openslideload documentation --- libvips/foreign/foreign.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/libvips/foreign/foreign.c b/libvips/foreign/foreign.c index 09e262d9..0f6cc8e0 100644 --- a/libvips/foreign/foreign.c +++ b/libvips/foreign/foreign.c @@ -2357,7 +2357,7 @@ vips_openexrload( const char *filename, VipsImage **out, ... ) * * Optional arguments: * - * @layer: load this layer + * @level: load this level * @associated: load this associated image * * Read a virtual slide supported by the OpenSlide library into a VIPS image. @@ -2366,9 +2366,8 @@ vips_openexrload( const char *filename, VipsImage **out, ... ) * * To facilitate zooming, virtual slide formats include multiple scaled-down * versions of the high-resolution image. These are typically called - * "levels", though OpenSlide and im_openslide2vips() call them "layers". - * By default, vips_openslideload() reads the highest-resolution layer - * (layer 0). Set @layer to the layer number you want. + * "levels". By default, vips_openslideload() reads the highest-resolution + * level (level 0). Set @level to the level number you want. * * In addition to the slide image itself, virtual slide formats sometimes * include additional images, such as a scan of the slide's barcode. From 524f37c1b989374f953f159074afa955d7ebe799 Mon Sep 17 00:00:00 2001 From: Benjamin Gilbert Date: Sun, 27 Oct 2013 22:16:35 -0400 Subject: [PATCH 2/4] drop error freeze/thaw around openslide_open() openslide_open() hasn't been able to cause a call to vips_error() since c98d6543. --- libvips/foreign/openslide2vips.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/libvips/foreign/openslide2vips.c b/libvips/foreign/openslide2vips.c index 59ccd931..2102f234 100644 --- a/libvips/foreign/openslide2vips.c +++ b/libvips/foreign/openslide2vips.c @@ -109,9 +109,7 @@ vips__openslide_isslide( const char *filename ) int ok; ok = 0; - vips_error_freeze(); osr = openslide_open( filename ); - vips_error_thaw(); if( osr ) { const char *vendor; From 2e8d01481198ac9edf70de89a5af3d219bb8e323 Mon Sep 17 00:00:00 2001 From: Benjamin Gilbert Date: Sat, 25 Jan 2014 02:31:20 -0500 Subject: [PATCH 3/4] update for new format support in OpenSlide 3.4.0 --- README.md | 2 +- libvips/deprecated/im_openslide2vips.c | 2 ++ libvips/foreign/foreign.c | 4 ++-- libvips/foreign/openslideload.c | 2 ++ 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 979fb164..820f139e 100644 --- a/README.md +++ b/README.md @@ -189,7 +189,7 @@ OpenEXR images. ## OpenSlide If available, libvips can load OpenSlide-supported virtual slide -files: Aperio, Hamamatsu VMS and VMU, Leica, MIRAX, and Trestle. +files: Aperio, Hamamatsu, Leica, MIRAX, Sakura, Trestle, and Ventana. ## swig, python, python-dev diff --git a/libvips/deprecated/im_openslide2vips.c b/libvips/deprecated/im_openslide2vips.c index a1c27d58..105ea762 100644 --- a/libvips/deprecated/im_openslide2vips.c +++ b/libvips/deprecated/im_openslide2vips.c @@ -98,7 +98,9 @@ static const char *openslide_suffs[] = { ".vms", ".vmu", ".ndpi", /* Hamamatsu */ ".scn", /* Leica */ ".mrxs", /* MIRAX */ + ".svslide", /* Sakura */ ".tif", /* Trestle */ + ".bif", /* Ventana */ NULL }; diff --git a/libvips/foreign/foreign.c b/libvips/foreign/foreign.c index 0f6cc8e0..eb91a9b8 100644 --- a/libvips/foreign/foreign.c +++ b/libvips/foreign/foreign.c @@ -2361,8 +2361,8 @@ vips_openexrload( const char *filename, VipsImage **out, ... ) * @associated: load this associated image * * Read a virtual slide supported by the OpenSlide library into a VIPS image. - * OpenSlide supports images in Aperio, Hamamatsu VMS, Hamamatsu VMU, MIRAX, - * and Trestle formats. + * OpenSlide supports images in Aperio, Hamamatsu, MIRAX, Sakura, Trestle, + * and Ventana formats. * * To facilitate zooming, virtual slide formats include multiple scaled-down * versions of the high-resolution image. These are typically called diff --git a/libvips/foreign/openslideload.c b/libvips/foreign/openslideload.c index 4d52301b..dc44d037 100644 --- a/libvips/foreign/openslideload.c +++ b/libvips/foreign/openslideload.c @@ -140,7 +140,9 @@ static const char *vips_foreign_openslide_suffs[] = { ".vms", ".vmu", ".ndpi", /* Hamamatsu */ ".scn", /* Leica */ ".mrxs", /* MIRAX */ + ".svslide", /* Sakura */ ".tif", /* Trestle */ + ".bif", /* Ventana */ NULL }; From ebf4fb807bf6ba92ffe2e89a52a161fed862c329 Mon Sep 17 00:00:00 2001 From: Benjamin Gilbert Date: Sat, 25 Jan 2014 02:56:27 -0500 Subject: [PATCH 4/4] use openslide_detect_vendor() on OpenSlide 3.4.0 It is much more efficient than openslide_open(). It also fixes a bug: If openslide_open() failed, we had no way of knowing whether it was an interesting failure (for relevant slide formats) or an uninteresting one (for a generic TIFF). So, the is_a method would always return false in this case. This could cause unexpected results; for example, on MIRAX slides, VIPS would open the .mrxs file itself (a JPEG thumbnail) and the user would be left wondering where all their pixels went. Now, if there is an interesting failure, is_a will succeed but header/load will fail. --- configure.ac | 15 +++++++++++---- libvips/foreign/openslide2vips.c | 22 +++++++++++++++++++++- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index 3a079bd9..183fac93 100644 --- a/configure.ac +++ b/configure.ac @@ -497,12 +497,19 @@ AC_ARG_WITH([openslide], AS_HELP_STRING([--without-openslide], [build without OpenSlide (default: test)])) if test x"$with_openslide" != x"no"; then - PKG_CHECK_MODULES(OPENSLIDE, openslide >= 3.3.0, - [AC_DEFINE(HAVE_OPENSLIDE,1,[define if you have OpenSlide >= 3.3.0 installed.]) + PKG_CHECK_MODULES(OPENSLIDE, [openslide >= 3.4.0], + [AC_DEFINE(HAVE_OPENSLIDE_3_4,1,[define if you have OpenSlide >= 3.4.0 installed.]) + AC_DEFINE(HAVE_OPENSLIDE,1,[define if you have OpenSlide >= 3.3.0 installed.]) with_openslide=yes PACKAGES_USED="$PACKAGES_USED openslide"], - [AC_MSG_WARN([OpenSlide >= 3.3.0 not found; disabling virtual slide support]) - with_openslide=no + [AC_MSG_NOTICE([OpenSlide >= 3.4.0 not found; checking for >= 3.3.0]) + PKG_CHECK_MODULES(OPENSLIDE, [openslide >= 3.3.0], + [AC_DEFINE(HAVE_OPENSLIDE,1,[define if you have OpenSlide >= 3.3.0 installed.]) + with_openslide=yes + PACKAGES_USED="$PACKAGES_USED openslide"], + [AC_MSG_WARN([OpenSlide >= 3.3.0 not found; disabling virtual slide support]) + with_openslide=no + ]) ]) fi diff --git a/libvips/foreign/openslide2vips.c b/libvips/foreign/openslide2vips.c index 2102f234..e68c6da8 100644 --- a/libvips/foreign/openslide2vips.c +++ b/libvips/foreign/openslide2vips.c @@ -2,7 +2,7 @@ * * Benjamin Gilbert * - * Copyright (c) 2011-2012 Carnegie Mellon University + * Copyright (c) 2011-2014 Carnegie Mellon University * * 26/11/11 * - initial version @@ -39,6 +39,8 @@ * - use threaded tile cache * 6/8/13 * - always output solid (not transparent) pixels + * 25/1/14 + * - use openslide_detect_vendor() on >= 3.4.0 */ /* @@ -105,6 +107,23 @@ typedef struct { int vips__openslide_isslide( const char *filename ) { +#ifdef HAVE_OPENSLIDE_3_4 + const char *vendor; + int ok; + + vendor = openslide_detect_vendor( filename ); + + /* Generic tiled tiff images can be opened by openslide as well. + * Only offer to load this file if it's not a generic tiff since + * we want vips_tiffload() to handle these. + */ + ok = ( vendor && + strcmp( vendor, "generic-tiff" ) != 0 ); + + VIPS_DEBUG_MSG( "vips__openslide_isslide: %s - %d\n", filename, ok ); + + return( ok ); +#else openslide_t *osr; int ok; @@ -133,6 +152,7 @@ vips__openslide_isslide( const char *filename ) VIPS_DEBUG_MSG( "vips__openslide_isslide: %s - %d\n", filename, ok ); return( ok ); +#endif } static void