added vips_image_write()
added a convenience function to write an image to a file
This commit is contained in:
parent
2ba39ebc23
commit
ef29872ce7
@ -363,6 +363,7 @@ VipsImage *vips_image_new_from_file_raw( const char *filename,
|
|||||||
VipsImage *vips_image_new_from_memory( void *buffer,
|
VipsImage *vips_image_new_from_memory( void *buffer,
|
||||||
int xsize, int ysize, int bands, VipsBandFormat bandfmt );
|
int xsize, int ysize, int bands, VipsBandFormat bandfmt );
|
||||||
VipsImage *vips_image_new_disc_temp( const char *format );
|
VipsImage *vips_image_new_disc_temp( const char *format );
|
||||||
|
int vips_image_write( VipsImage *image, const char *filename );
|
||||||
|
|
||||||
gboolean vips_image_isMSBfirst( VipsImage *image );
|
gboolean vips_image_isMSBfirst( VipsImage *image );
|
||||||
gboolean vips_image_isfile( VipsImage *image );
|
gboolean vips_image_isfile( VipsImage *image );
|
||||||
|
@ -1736,6 +1736,31 @@ vips_image_new_disc_temp( const char *format )
|
|||||||
return( image );
|
return( image );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* vips_image_write:
|
||||||
|
* @image: image to write
|
||||||
|
* @filename: write to this file
|
||||||
|
*
|
||||||
|
* A convenience function to write a #VipsImage to a file.
|
||||||
|
*
|
||||||
|
* Returns: 0 on success, or -1 on error.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
vips_image_write( VipsImage *image, const char *filename )
|
||||||
|
{
|
||||||
|
VipsImage *out;
|
||||||
|
|
||||||
|
if( !(out = vips_image_new_from_file( filename, "w" )) )
|
||||||
|
return( -1 );
|
||||||
|
if( im_copy( image, out ) ) {
|
||||||
|
g_object_unref( out );
|
||||||
|
return( -1 );
|
||||||
|
}
|
||||||
|
g_object_unref( out );
|
||||||
|
|
||||||
|
return( 0 );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* vips_image_isMSBfirst:
|
* vips_image_isMSBfirst:
|
||||||
* @image: image to test
|
* @image: image to test
|
||||||
|
@ -1164,18 +1164,13 @@ vips_object_get_argument_to_string( VipsObject *object,
|
|||||||
if( G_IS_PARAM_SPEC_OBJECT( pspec ) &&
|
if( G_IS_PARAM_SPEC_OBJECT( pspec ) &&
|
||||||
G_PARAM_SPEC_VALUE_TYPE( pspec ) == VIPS_TYPE_IMAGE ) {
|
G_PARAM_SPEC_VALUE_TYPE( pspec ) == VIPS_TYPE_IMAGE ) {
|
||||||
VipsImage *value;
|
VipsImage *value;
|
||||||
VipsImage *image;
|
|
||||||
|
|
||||||
if( !(image = vips_image_new_from_file( arg, "w" )) )
|
|
||||||
return( -1 );
|
|
||||||
g_object_get( object, name, &value, NULL );
|
g_object_get( object, name, &value, NULL );
|
||||||
if( im_copy( value, image ) ) {
|
if( vips_image_write( value, arg ) ) {
|
||||||
g_object_unref( value );
|
g_object_unref( value );
|
||||||
g_object_unref( image );
|
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
g_object_unref( value );
|
g_object_unref( value );
|
||||||
g_object_unref( image );
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
char str[1000];
|
char str[1000];
|
||||||
|
Loading…
Reference in New Issue
Block a user