stage1 seems to work

This commit is contained in:
John Cupitt 2014-06-07 16:47:53 +01:00
parent 339712fb13
commit d426abdcd8
9 changed files with 50 additions and 23 deletions

7
TODO
View File

@ -12,9 +12,16 @@
see vips_foreign_load_buffer() for API
- can get rid of vips_foreign_load() / vips_foreign_save()
also vips_foreign_load_from_buffer() or whatever it's called, and save too.
- do we still need all the vips_image_build() machinery? can't we just use
the foreign system?
only need a couple of basic modes:wq

View File

@ -404,6 +404,12 @@ vips_flags( const char *filename )
typedef VipsFormat VipsFormatVips;
typedef VipsFormatClass VipsFormatVipsClass;
static int
vips_format_vips_save( VipsImage *image, const char *filename )
{
return( vips_image_write_to_file( image, filename, NULL ) );
}
static void
vips_format_vips_class_init( VipsFormatVipsClass *class )
{
@ -417,7 +423,7 @@ vips_format_vips_class_init( VipsFormatVipsClass *class )
format_class->is_a = im_isvips;
format_class->header = file2vips;
format_class->load = file2vips;
format_class->save = vips_image_write_to_file;
format_class->save = vips_format_vips_save;
format_class->get_flags = vips_flags;
format_class->suffs = vips_suffs;
}

View File

@ -91,7 +91,7 @@ vips_foreign_load_vips_header( VipsForeignLoad *load )
VipsImage *out;
VipsImage *out2;
if( !(out2 = vips_image_new_mode( vips->filename, "r" ) )
if( !(out2 = vips_image_new_mode( vips->filename, "r" )) )
return( -1 );
/* Remove the @out that's there now.

View File

@ -65,12 +65,19 @@ vips_foreign_save_vips_build( VipsObject *object )
VipsForeignSave *save = (VipsForeignSave *) object;
VipsForeignSaveVips *vips = (VipsForeignSaveVips *) object;
VipsImage *x;
if( VIPS_OBJECT_CLASS( vips_foreign_save_vips_parent_class )->
build( object ) )
return( -1 );
if( vips_image_write_to_file( save->ready, vips->filename ) )
if( !(x = vips_image_new_mode( vips->filename, "w" )) )
return( -1 );
if( vips_image_write( save->ready, x ) ) {
g_object_unref( x );
return( -1 );
}
g_object_unref( x );
return( 0 );
}

View File

@ -474,7 +474,8 @@ vips_image_to_string( VipsObject *object, VipsBuf *buf )
static int
vips_image_write_object( VipsObject *object, const char *string )
{
return( vips_image_write_to_file( VIPS_IMAGE( object ), string ) );
return( vips_image_write_to_file( VIPS_IMAGE( object ), string,
NULL ) );
}
static void *
@ -755,6 +756,11 @@ vips_image_add_progress( VipsImage *image )
}
}
/* We have to do a lot of work in _build() so we can work with the stuff in
* /deprecated to support the vips7 API. We could get rid of most of this
* stuff if we were vips8-only.
*/
static int
vips_image_build( VipsObject *object )
{
@ -1540,6 +1546,9 @@ vips_image_new( void )
* vips_image_new_mode() examines the mode string and creates an
* appropriate #VipsImage.
*
* This function (mostly) exists to support the vips7 compatibility layer.
* vips8 programs should use vips_image_new_from_file() and friends.
*
* <itemizedlist>
* <listitem>
* <para>
@ -1699,18 +1708,16 @@ vips_image_new_from_file( const char *name, ... )
VipsImage *out;
int result;
/* Sniff the file type and select a load operation.
*/
vips__filename_split8( name, filename, option_string );
if( !(operation_name = vips_foreign_find_load( filename )) )
return( -1 );
return( NULL );
va_start( ap, out );
va_start( ap, name );
result = vips_call_split_option_string( operation_name, option_string,
ap, filename, &out );
va_end( ap );
if( !result )
if( result )
return( NULL );
return( out );
@ -2006,8 +2013,9 @@ vips_image_write( VipsImage *image, VipsImage *out )
* Writes @in to @name using the saver recommended by
* vips_foreign_find_save().
*
* Save options may be appended to @name as "[name=value,...]" or given as
* a NULL-terminated list of name-value pairs at the end of the arguments.
* Save options may be appended to @filename as "[name=value,...]" or given as
* a NULL-terminated list of name-value pairs at the end of the arguments.
* Options given in the function call override options given in the filename.
*
* See also: vips_image_new_from_file().
*
@ -2023,13 +2031,12 @@ vips_image_write_to_file( VipsImage *image, const char *name, ... )
int result;
vips__filename_split8( name, filename, option_string );
if( !(operation_name = vips_foreign_find_save( filename )) )
return( -1 );
va_start( ap, name );
result = vips_call_split_option_string( operation_name, option_string,
ap, in, filename );
ap, image, filename );
va_end( ap );
return( result );

View File

@ -145,7 +145,7 @@ vips_system_build( VipsObject *object )
vips__temp_name( in_format )) )
return( -1 );
if( vips_image_write_to_file( in[i],
system->in_name[i] ) )
system->in_name[i], NULL ) )
return( -1 );
}
}

View File

@ -1334,7 +1334,7 @@ vips__find_rightmost_brackets( const char *p )
/* Split a vips8-style filename + options.
*
* filename and options must be VIPS_PATH_MAX in length.
* filename and option_string must be VIPS_PATH_MAX in length.
*/
void
vips__filename_split8( const char *name, char *filename, char *option_string )

View File

@ -210,7 +210,7 @@ main( int argc, char *argv[] )
for( i = 1; i < argc; i++ ) {
VipsImage *im;
if( !(im = vips_image_new_from_file( argv[i] )) ) {
if( !(im = vips_image_new_from_file( argv[i], NULL )) ) {
print_error();
result = 1;
}

View File

@ -266,7 +266,7 @@ thumbnail_open( VipsObject *process, const char *filename )
/* This will just read in the header and is quick.
*/
if( !(im = vips_image_new_from_file( filename )) )
if( !(im = vips_image_new_from_file( filename, NULL )) )
return( NULL );
jpegshrink = thumbnail_find_jpegshrink( im );
@ -277,18 +277,18 @@ thumbnail_open( VipsObject *process, const char *filename )
"loading jpeg with factor %d pre-shrink",
jpegshrink );
if( vips_foreign_load( filename, &im,
if( !(im = vips_image_new_from_file( filename,
"access", VIPS_ACCESS_SEQUENTIAL,
"shrink", jpegshrink,
NULL ) )
NULL )) )
return( NULL );
}
else {
/* All other formats.
*/
if( vips_foreign_load( filename, &im,
if( !(im = vips_image_new_from_file( filename,
"access", VIPS_ACCESS_SEQUENTIAL,
NULL ) )
NULL )) )
return( NULL );
}
@ -337,7 +337,7 @@ thumbnail_sharpen( VipsObject *process )
}
else
if( !(mask =
vips_image_new_from_file( convolution_mask )) )
vips_image_new_from_file( convolution_mask, NULL )) )
vips_error_exit( "unable to load sharpen mask" );
if( mask )
@ -599,7 +599,7 @@ thumbnail_write( VipsImage *im, const char *filename )
g_free( file );
if( vips_image_write_to_file( im, output_name ) ) {
if( vips_image_write_to_file( im, output_name, NULL ) ) {
g_free( output_name );
return( -1 );
}