Merge branch 'master' into add-tiffload-n-pages
This commit is contained in:
commit
5a61374bbf
@ -8,7 +8,7 @@
|
||||
- added vips_thumbnail() / vips_thumbnail_buffer()
|
||||
- better >4gb detect for zip dzsave output [Felix Bünemann]
|
||||
- all loaders have a @fail option, meaning fail on first warning, though it
|
||||
only does anything for jpg, csv, openslide
|
||||
only does anything for jpg and csv
|
||||
- add vips_image_get_fields() to help bindings
|
||||
- add multi-page read to tiffload
|
||||
|
||||
|
@ -47,8 +47,6 @@
|
||||
* - do argb -> rgba for associated as well
|
||||
* 27/1/15
|
||||
* - unpremultiplication speedups for fully opaque/transparent pixels
|
||||
* 11/7/16
|
||||
* - just warn on tile read error
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -115,10 +113,6 @@ typedef struct {
|
||||
*/
|
||||
int tile_width;
|
||||
int tile_height;
|
||||
|
||||
/* Quit on warning.
|
||||
*/
|
||||
gboolean fail;
|
||||
} ReadSlide;
|
||||
|
||||
int
|
||||
@ -227,7 +221,7 @@ get_bounds( openslide_t *osr, VipsRect *rect )
|
||||
|
||||
static ReadSlide *
|
||||
readslide_new( const char *filename, VipsImage *out,
|
||||
int level, gboolean autocrop, const char *associated, gboolean fail )
|
||||
int level, gboolean autocrop, const char *associated )
|
||||
{
|
||||
ReadSlide *rslide;
|
||||
int64_t w, h;
|
||||
@ -395,9 +389,9 @@ readslide_new( const char *filename, VipsImage *out,
|
||||
|
||||
int
|
||||
vips__openslide_read_header( const char *filename, VipsImage *out,
|
||||
int level, gboolean autocrop, char *associated, gboolean fail )
|
||||
int level, gboolean autocrop, char *associated )
|
||||
{
|
||||
if( !readslide_new( filename, out, level, autocrop, associated, fail ) )
|
||||
if( !readslide_new( filename, out, level, autocrop, associated ) )
|
||||
return( -1 );
|
||||
|
||||
return( 0 );
|
||||
@ -477,15 +471,18 @@ vips__openslide_generate( VipsRegion *out,
|
||||
rslide->level,
|
||||
r->width, r->height );
|
||||
|
||||
/* Only warn on error: we don't want to make the whole image unreadable
|
||||
* because of one broken tile.
|
||||
/* openslide errors are terminal. To support
|
||||
* @fail we'd have to close the openslide_t and reopen, perhaps
|
||||
* somehow marking this tile as unreadable.
|
||||
*
|
||||
* See
|
||||
* https://github.com/jcupitt/libvips/commit/bb0a6643f94e69294e36d2b253f9bdd60c8c40ed#commitcomment-19838911
|
||||
*/
|
||||
error = openslide_get_error( rslide->osr );
|
||||
if( error ) {
|
||||
vips_warn( "openslide2vips",
|
||||
vips_error( "openslide2vips",
|
||||
_( "reading region: %s" ), error );
|
||||
if( rslide->fail )
|
||||
return( -1 );
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
/* Since we are inside a cache, we know buf must be continuous.
|
||||
@ -497,7 +494,7 @@ vips__openslide_generate( VipsRegion *out,
|
||||
|
||||
int
|
||||
vips__openslide_read( const char *filename, VipsImage *out,
|
||||
int level, gboolean autocrop, gboolean fail )
|
||||
int level, gboolean autocrop )
|
||||
{
|
||||
ReadSlide *rslide;
|
||||
VipsImage *raw;
|
||||
@ -510,7 +507,7 @@ vips__openslide_read( const char *filename, VipsImage *out,
|
||||
vips_object_local( out, raw );
|
||||
|
||||
if( !(rslide = readslide_new( filename, raw,
|
||||
level, autocrop, NULL, fail )) )
|
||||
level, autocrop, NULL )) )
|
||||
return( -1 );
|
||||
|
||||
if( vips_image_generate( raw,
|
||||
@ -539,7 +536,7 @@ vips__openslide_read( const char *filename, VipsImage *out,
|
||||
|
||||
int
|
||||
vips__openslide_read_associated( const char *filename, VipsImage *out,
|
||||
const char *associated, gboolean fail )
|
||||
const char *associated )
|
||||
{
|
||||
ReadSlide *rslide;
|
||||
VipsImage *raw;
|
||||
@ -554,8 +551,7 @@ vips__openslide_read_associated( const char *filename, VipsImage *out,
|
||||
raw = vips_image_new_memory();
|
||||
vips_object_local( out, raw );
|
||||
|
||||
if( !(rslide = readslide_new( filename, raw,
|
||||
0, FALSE, associated, fail )) ||
|
||||
if( !(rslide = readslide_new( filename, raw, 0, FALSE, associated )) ||
|
||||
vips_image_write_prepare( raw ) )
|
||||
return( -1 );
|
||||
buf = (uint32_t *) VIPS_IMAGE_ADDR( raw, 0, 0 );
|
||||
|
@ -114,7 +114,7 @@ vips_foreign_load_openslide_header( VipsForeignLoad *load )
|
||||
|
||||
if( vips__openslide_read_header( openslide->filename, load->out,
|
||||
openslide->level, openslide->autocrop,
|
||||
openslide->associated, load->fail ) )
|
||||
openslide->associated ) )
|
||||
return( -1 );
|
||||
|
||||
VIPS_SETSTR( load->out->filename, openslide->filename );
|
||||
@ -129,13 +129,12 @@ vips_foreign_load_openslide_load( VipsForeignLoad *load )
|
||||
|
||||
if( !openslide->associated ) {
|
||||
if( vips__openslide_read( openslide->filename, load->real,
|
||||
openslide->level, openslide->autocrop, load->fail ) )
|
||||
openslide->level, openslide->autocrop ) )
|
||||
return( -1 );
|
||||
}
|
||||
else {
|
||||
if( vips__openslide_read_associated(
|
||||
openslide->filename, load->real,
|
||||
openslide->associated, load->fail ) )
|
||||
if( vips__openslide_read_associated( openslide->filename,
|
||||
load->real, openslide->associated ) )
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
@ -231,7 +230,6 @@ vips_foreign_load_openslide_init( VipsForeignLoadOpenslide *openslide )
|
||||
* * @level: load this level
|
||||
* * @associated: load this associated image
|
||||
* * @autocrop: crop to image bounds
|
||||
* * @fail: %gboolean, fail on warnings
|
||||
*
|
||||
* Read a virtual slide supported by the OpenSlide library into a VIPS image.
|
||||
* OpenSlide supports images in Aperio, Hamamatsu, MIRAX, Sakura, Trestle,
|
||||
@ -251,8 +249,6 @@ vips_foreign_load_openslide_init( VipsForeignLoadOpenslide *openslide )
|
||||
*
|
||||
* The output of this operator is always RGBA.
|
||||
*
|
||||
* Setting @fail to %TRUE makes the reader fail on any warnings.
|
||||
*
|
||||
* See also: vips_image_new_from_file().
|
||||
*
|
||||
* Returns: 0 on success, -1 on error.
|
||||
|
@ -217,11 +217,11 @@ int vips__webp_write_buffer( VipsImage *out, void **buf, size_t *len,
|
||||
|
||||
int vips__openslide_isslide( const char *filename );
|
||||
int vips__openslide_read_header( const char *filename, VipsImage *out,
|
||||
int level, gboolean autocrop, char *associated, gboolean fail );
|
||||
int level, gboolean autocrop, char *associated );
|
||||
int vips__openslide_read( const char *filename, VipsImage *out,
|
||||
int level, gboolean autocrop, gboolean fail );
|
||||
int level, gboolean autocrop );
|
||||
int vips__openslide_read_associated( const char *filename, VipsImage *out,
|
||||
const char *associated, gboolean fail );
|
||||
const char *associated );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -190,6 +190,7 @@ int vips_image_get_string( const VipsImage *image,
|
||||
const char *name, const char **out );
|
||||
void vips_image_set_string( VipsImage *image,
|
||||
const char *name, const char *str );
|
||||
void vips_image_print_field( const VipsImage *image, const char *field );
|
||||
|
||||
int vips_image_history_printf( VipsImage *image, const char *format, ... )
|
||||
__attribute__((format(printf, 2, 3)));
|
||||
|
@ -893,8 +893,11 @@ vips__image_copy_fields_array( VipsImage *out, VipsImage *in[] )
|
||||
|
||||
/* Need to copy last-to-first so that in0 meta will override any
|
||||
* earlier meta.
|
||||
*
|
||||
* Don't destroy the meta on out. Things like foreign.c like setting
|
||||
* image properties before calling a subclass loader, and those
|
||||
* subclass loaders will sometimes write to an image.
|
||||
*/
|
||||
vips__meta_destroy( out );
|
||||
for( i = ni - 1; i >= 0; i-- )
|
||||
if( meta_cp( out, in[i] ) )
|
||||
return( -1 );
|
||||
@ -1573,6 +1576,28 @@ vips_image_get_as_string( const VipsImage *image,
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
/**
|
||||
* vips_image_print_field:
|
||||
* @image: image to get the header field from
|
||||
* @field: field name
|
||||
*
|
||||
* Prints a field to stdout as ASCII. Handy for debugging.
|
||||
*/
|
||||
void
|
||||
vips_image_print_field( const VipsImage *image, const char *field )
|
||||
{
|
||||
char *str;
|
||||
|
||||
if( vips_image_get_as_string( image, field, &str ) ) {
|
||||
printf( "vips_image_print_field: unable to read field\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
printf( ".%s: %s\n", field, str );
|
||||
|
||||
g_free( str );
|
||||
}
|
||||
|
||||
/**
|
||||
* vips_image_history_printf:
|
||||
* @image: add history line to this image
|
||||
|
@ -64,7 +64,15 @@
|
||||
* sort of 2D transform which preserves straight lines; so any combination of
|
||||
* stretch, sheer, rotate and translate. You supply an interpolator for it to
|
||||
* use to generate pixels, see vips_interpolate_new(). It will not produce
|
||||
* good results for very large shrinks.
|
||||
* good results for very large shrinks: you'll see aliasing.
|
||||
*
|
||||
* vips_reduce() is like vips_affine(), but it can only shrink images, it can't
|
||||
* enlarge, rotate, or skew. It's very fast and uses an adaptive kernel for
|
||||
* interpolation. Again, it will give poor results for large size reductions.
|
||||
*
|
||||
* vips_shrink() is a fast block shrinker. It can quickly reduce images by
|
||||
* large integer factors. It will give poor results for small size reductions:
|
||||
* again, you'll see aliasing.
|
||||
*
|
||||
* Next, vips_resize() specialises in the common task of image reduce and
|
||||
* enlarge. It strings together combinations of vips_shrink(), vips_reduce(),
|
||||
|
Loading…
Reference in New Issue
Block a user