im_copy_file() -> vips_copy_file()
also rename vips_image_new_disc_tmpe() as vips_image_new_temp_file()
This commit is contained in:
parent
5e1027f6e5
commit
42b4dd947d
@ -3,7 +3,7 @@
|
||||
- turn off caching for im_copy()/vips_copy(), we use copy to stop sharing, and
|
||||
it's cheap so caching doesn't help anyway
|
||||
- auto rshift down to 8 bits on save, if necessary
|
||||
- im_gaussnoise() redone as a class
|
||||
- im_gaussnoise(), im_copy_file() redone as a class
|
||||
- add --angle option to dzsave
|
||||
|
||||
14/5/13 started 7.32.4
|
||||
|
@ -26,7 +26,6 @@ libconversion_la_SOURCES = \
|
||||
rot.c \
|
||||
ifthenelse.c \
|
||||
conver_dispatch.c \
|
||||
im_copy_file.c \
|
||||
im_falsecolour.c \
|
||||
im_msb.c \
|
||||
im_grid.c \
|
||||
|
@ -459,3 +459,39 @@ vips_copy( VipsImage *in, VipsImage **out, ... )
|
||||
|
||||
return( result );
|
||||
}
|
||||
|
||||
/**
|
||||
* vips_copy_file:
|
||||
* @in: input image
|
||||
* @out: output image
|
||||
*
|
||||
* A simple convenience function to copy an image to a file, then copy
|
||||
* again to output. If the image is already a file, just copy straight
|
||||
* through.
|
||||
*
|
||||
* The file is allocated with vips_image_new_temp_file().
|
||||
* The file is automatically deleted when @out is closed.
|
||||
*
|
||||
* See also: vips_copy(), vips_image_new_temp_file().
|
||||
*
|
||||
* Returns: 0 on success, -1 on error
|
||||
*/
|
||||
int
|
||||
vips_copy_file( VipsImage *in, VipsImage **out )
|
||||
{
|
||||
VipsImage *file;
|
||||
|
||||
if( vips_image_isfile( in ) )
|
||||
return( vips_copy( in, out, NULL ) );
|
||||
|
||||
if( !(file = vips_image_new_temp_file( "%s.v" )) )
|
||||
return( -1 );
|
||||
if( vips_image_write( in, file ) ||
|
||||
vips_copy( file, out, NULL ) ) {
|
||||
g_object_unref( file );
|
||||
return( -1 );
|
||||
}
|
||||
g_object_unref( file );
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
@ -1,90 +0,0 @@
|
||||
/* copy an image to a file and then copy that to the output ... a disc cache
|
||||
*
|
||||
* 16/10/09
|
||||
* - from im_system()
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
This file is part of VIPS.
|
||||
|
||||
VIPS is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk
|
||||
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif /*HAVE_CONFIG_H*/
|
||||
#include <vips/intl.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif /*HAVE_UNISTD_H*/
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <vips/vips.h>
|
||||
|
||||
/**
|
||||
* im_copy_file:
|
||||
* @in: input image
|
||||
* @out: output image
|
||||
*
|
||||
* Copy an image to a disc file, then copy again to output. If the image is
|
||||
* already a disc file, just copy straight through.
|
||||
*
|
||||
* The disc file is allocated in the same way as im_system_image().
|
||||
* The file is automatically deleted when @out is closed.
|
||||
*
|
||||
* See also: im_copy(), im_system_image().
|
||||
*
|
||||
* Returns: 0 on success, -1 on error
|
||||
*/
|
||||
int
|
||||
im_copy_file( IMAGE *in, IMAGE *out )
|
||||
{
|
||||
if( !im_isfile( in ) ) {
|
||||
IMAGE *disc;
|
||||
|
||||
if( !(disc = im__open_temp( "%s.v" )) )
|
||||
return( -1 );
|
||||
if( im_add_close_callback( out,
|
||||
(im_callback_fn) im_close, disc, NULL ) ) {
|
||||
im_close( disc );
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
if( im_copy( in, disc ) ||
|
||||
im_copy( disc, out ) )
|
||||
return( -1 );
|
||||
}
|
||||
else {
|
||||
if( im_copy( in, out ) )
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
return( 0 );
|
||||
}
|
@ -144,7 +144,7 @@ lazy_real_image( Lazy *lazy )
|
||||
!(vips_format_get_flags( lazy->format, lazy->filename ) &
|
||||
VIPS_FORMAT_PARTIAL) &&
|
||||
VIPS_IMAGE_SIZEOF_IMAGE( lazy->image ) > disc_threshold() )
|
||||
if( !(real = vips_image_new_disc_temp( "%s.v" )) )
|
||||
if( !(real = vips_image_new_temp_file( "%s.v" )) )
|
||||
return( NULL );
|
||||
|
||||
/* Otherwise, fall back to a "p".
|
||||
|
@ -3042,3 +3042,19 @@ vips__affine( VipsImage *in, VipsImage *out, VipsTransformation *trn )
|
||||
return( im__affinei( in, out,
|
||||
vips_interpolate_bilinear_static(), trn ) );
|
||||
}
|
||||
|
||||
int
|
||||
im_copy_file( IMAGE *in, IMAGE *out )
|
||||
{
|
||||
VipsImage *x;
|
||||
|
||||
if( vips_copy_file( in, &x ) )
|
||||
return( -1 );
|
||||
if( im_copy( x, out ) ) {
|
||||
g_object_unref( x );
|
||||
return( -1 );
|
||||
}
|
||||
g_object_unref( x );
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
@ -725,7 +725,7 @@ vips_foreign_load_temp( VipsForeignLoad *load )
|
||||
printf( "vips_foreign_load_temp: disc temp\n" );
|
||||
#endif /*DEBUG*/
|
||||
|
||||
return( vips_image_new_disc_temp( "%s.v" ) );
|
||||
return( vips_image_new_temp_file( "%s.v" ) );
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
|
@ -168,6 +168,7 @@ int vips_sequential( VipsImage *in, VipsImage **out, ... )
|
||||
__attribute__((sentinel));
|
||||
int vips_cache( VipsImage *in, VipsImage **out, ... )
|
||||
__attribute__((sentinel));
|
||||
int vips_copy_file( VipsImage *in, VipsImage **out );
|
||||
|
||||
int vips_embed( VipsImage *in, VipsImage **out,
|
||||
int x, int y, int width, int height, ... )
|
||||
@ -248,8 +249,6 @@ int vips_flatten( VipsImage *in, VipsImage **out, ... )
|
||||
|
||||
|
||||
|
||||
int im_copy_file( VipsImage *in, VipsImage *out );
|
||||
|
||||
int im_scale( VipsImage *in, VipsImage *out );
|
||||
int im_msb( VipsImage *in, VipsImage *out );
|
||||
int im_msb_band( VipsImage *in, VipsImage *out, int band );
|
||||
|
@ -509,7 +509,7 @@ VipsImage *vips_image_new_from_memory( void *buffer,
|
||||
VipsImage *vips_image_new_array( int xsize, int ysize );
|
||||
void vips_image_set_delete_on_close( VipsImage *image,
|
||||
gboolean delete_on_close );
|
||||
VipsImage *vips_image_new_disc_temp( const char *format );
|
||||
VipsImage *vips_image_new_temp_file( const char *format );
|
||||
int vips_image_write( VipsImage *image, VipsImage *out );
|
||||
int vips_image_write_to_file( VipsImage *image, const char *filename );
|
||||
|
||||
|
@ -214,7 +214,7 @@ extern "C" {
|
||||
#define im_cp_desc_array vips_image_copy_fields_array
|
||||
#define im_image vips_image_new_from_memory
|
||||
#define im_binfile vips_image_new_from_file_raw
|
||||
#define im__open_temp vips_image_new_disc_temp
|
||||
#define im__open_temp vips_image_new_temp_file
|
||||
#define im__test_kill( I ) (vips_image_get_kill( I ))
|
||||
#define im__start_eval( I ) (vips_image_preeval( I ), vips_image_get_kill( I ))
|
||||
#define im__handle_eval( I, W, H ) \
|
||||
@ -688,6 +688,7 @@ int im_copy_set_meta( VipsImage *in, VipsImage *out,
|
||||
int im_copy_morph( VipsImage *in, VipsImage *out,
|
||||
int bands, VipsBandFormat format, VipsCoding coding );
|
||||
int im_copy_swap( VipsImage *in, VipsImage *out );
|
||||
int im_copy_file( VipsImage *in, VipsImage *out );
|
||||
int im_copy_native( VipsImage *in, VipsImage *out, gboolean is_msb_first );
|
||||
int im_embed( VipsImage *in, VipsImage *out,
|
||||
int type, int x, int y, int width, int height );
|
||||
|
@ -1410,7 +1410,7 @@ vips_image_new( void )
|
||||
* API and control the loading process yourself. See
|
||||
* #VipsForeign.
|
||||
*
|
||||
* See im_system_image() for an explanation of how VIPS selects a
|
||||
* See vips_image_new_temp_file() for an explanation of how VIPS selects a
|
||||
* location for the temporary file.
|
||||
*
|
||||
* The disc threshold can be set with the "--vips-disc-threshold"
|
||||
@ -1662,7 +1662,7 @@ vips_image_new_array( int xsize, int ysize )
|
||||
*
|
||||
* This function is clearly extremely dangerous, use with great caution.
|
||||
*
|
||||
* See also: vips__temp_name(), vips_image_new_disc_temp().
|
||||
* See also: vips__temp_name(), vips_image_new_temp_file().
|
||||
*/
|
||||
void
|
||||
vips_image_set_delete_on_close( VipsImage *image, gboolean delete_on_close )
|
||||
@ -1677,7 +1677,7 @@ vips_image_set_delete_on_close( VipsImage *image, gboolean delete_on_close )
|
||||
}
|
||||
|
||||
/**
|
||||
* vips_image_new_disc_temp:
|
||||
* vips_image_new_temp_file:
|
||||
* @format: format of file
|
||||
*
|
||||
* Make a "w" disc #VipsImage which will be automatically unlinked when it is
|
||||
@ -1690,7 +1690,7 @@ vips_image_set_delete_on_close( VipsImage *image, gboolean delete_on_close )
|
||||
* Returns: the new #VipsImage, or %NULL on error.
|
||||
*/
|
||||
VipsImage *
|
||||
vips_image_new_disc_temp( const char *format )
|
||||
vips_image_new_temp_file( const char *format )
|
||||
{
|
||||
char *name;
|
||||
VipsImage *image;
|
||||
|
Loading…
Reference in New Issue
Block a user