Skip to content
Permalink
Browse files

don't use new source API for new_from_file etc.

We were attempting to load images in new_from_file using the new source
API first, then only falling back to the file loaders if that failed.

However, this meant that we did not respect the priority ordering on
loaders, so openslide iamges (for example) were being loaded by the tiff
loader.
  • Loading branch information
jcupitt committed Jan 9, 2020
1 parent 1338def commit 51fc2ff64eb77260272943678a1f247d6abaa143
Showing with 24 additions and 63 deletions.
  1. +4 −0 ChangeLog
  2. +3 −3 configure.ac
  3. +17 −60 libvips/iofuncs/image.c
@@ -1,3 +1,7 @@
20/6/19 started 8.9.1
- don't use the new source loaders for new_from_file or new_from_buffer, it
will break the loader priority system

20/6/19 started 8.9.0
- add vips_image_get/set_array_int()
- disable webp alpha output if all frame fill the canvas and are solid
@@ -2,7 +2,7 @@

# also update the version number in the m4 macros below

AC_INIT([vips], [8.9.0], [vipsip@jiscmail.ac.uk])
AC_INIT([vips], [8.9.1], [vipsip@jiscmail.ac.uk])
# required for gobject-introspection
AC_PREREQ(2.62)

@@ -18,7 +18,7 @@ AC_CONFIG_MACRO_DIR([m4])
# user-visible library versioning
m4_define([vips_major_version], [8])
m4_define([vips_minor_version], [9])
m4_define([vips_micro_version], [0])
m4_define([vips_micro_version], [1])
m4_define([vips_version],
[vips_major_version.vips_minor_version.vips_micro_version])

@@ -38,7 +38,7 @@ VIPS_VERSION_STRING=$VIPS_VERSION-`date -u -r ChangeLog`
# binary interface changes not backwards compatible?: reset age to 0

LIBRARY_CURRENT=54
LIBRARY_REVISION=0
LIBRARY_REVISION=1
LIBRARY_AGE=12

# patched into include/vips/version.h
@@ -1907,7 +1907,6 @@ vips_image_new_from_file( const char *name, ... )
{
char filename[VIPS_PATH_MAX];
char option_string[VIPS_PATH_MAX];
VipsSource *source;
const char *operation_name;
va_list ap;
int result;
@@ -1917,37 +1916,13 @@ vips_image_new_from_file( const char *name, ... )

vips__filename_split8( name, filename, option_string );

/* Search with the new source API first, then fall back to the older
* mechanism in case the loader we need has not been converted yet.
*
* We need to hide any errors from this first phase.
*/
if( !(source = vips_source_new_from_file( filename )) )
if( !(operation_name = vips_foreign_find_load( filename )) )
return( NULL );

vips_error_freeze();
operation_name = vips_foreign_find_load_source( source );
vips_error_thaw();

if( operation_name ) {
va_start( ap, name );
result = vips_call_split_option_string( operation_name,
option_string, ap, source, &out );
va_end( ap );
}
else {
/* Fall back to the old file loader system.
*/
if( !(operation_name = vips_foreign_find_load( filename )) )
return( NULL );

va_start( ap, name );
result = vips_call_split_option_string( operation_name,
option_string, ap, filename, &out );
va_end( ap );
}

VIPS_UNREF( source );
va_start( ap, name );
result = vips_call_split_option_string( operation_name,
option_string, ap, filename, &out );
va_end( ap );

if( result )
return( NULL );
@@ -2159,46 +2134,28 @@ VipsImage *
vips_image_new_from_buffer( const void *buf, size_t len,
const char *option_string, ... )
{
VipsSource *source;
const char *operation_name;
va_list ap;
int result;
VipsImage *out;
VipsBlob *blob;

vips_check_init();

/* Search with the new source API first, then fall back to the older
* mechanism in case the loader we need has not been converted yet.
*/
if( !(source = vips_source_new_from_memory( buf, len )) )
return( NULL );

if( (operation_name = vips_foreign_find_load_source( source )) ) {
va_start( ap, option_string );
result = vips_call_split_option_string( operation_name,
option_string, ap, source, &out );
va_end( ap );
}
else {
VipsBlob *blob;

if( !(operation_name =
vips_foreign_find_load_buffer( buf, len )) )
return( NULL );

/* We don't take a copy of the data or free it.
*/
blob = vips_blob_new( NULL, buf, len );
if( !(operation_name =
vips_foreign_find_load_buffer( buf, len )) )
return( NULL );

va_start( ap, option_string );
result = vips_call_split_option_string( operation_name,
option_string, ap, blob, &out );
va_end( ap );
/* We don't take a copy of the data or free it.
*/
blob = vips_blob_new( NULL, buf, len );

vips_area_unref( VIPS_AREA( blob ) );
}
va_start( ap, option_string );
result = vips_call_split_option_string( operation_name,
option_string, ap, blob, &out );
va_end( ap );

VIPS_UNREF( source );
vips_area_unref( VIPS_AREA( blob ) );

if( result )
return( NULL );

0 comments on commit 51fc2ff

Please sign in to comment.
You can’t perform that action at this time.