From 7fdeb1789b33e1676689db0f7d757096a9f2d609 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Wed, 19 Oct 2011 10:53:18 +0100 Subject: [PATCH] vips7wrap works for non-image output "vips max x.jpg" now works --- TODO | 16 +++++++------ libvips/deprecated/wrapvips7.c | 41 ++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 7 deletions(-) diff --git a/TODO b/TODO index 2d124ff7..a1b1f49d 100644 --- a/TODO +++ b/TODO @@ -1,8 +1,3 @@ -- try - - $ vips max poop.jpg --vips-leak - - need to implement output double args in wrapvips7.c - try @@ -44,10 +39,17 @@ additionally, exif tags can be in one of several ifd blocks, do we need to add the tag to the correct block? how do we save that information? - probably not possible with libexif, better to pass the problem to another - library and simply provide operations to add and remove whole exif blocks + oo! we have the original, of course + to reattach, get the entry from the original exif block, get the updated + tag, coerce the updated value back to the orginal format + save exif entries to tags as something like: + + exif-Orientation: 1 (Top-left, Short, 1 component, 2 bytes) + + so we can restore the value from the "1" without needding to look up i18n + strings diff --git a/libvips/deprecated/wrapvips7.c b/libvips/deprecated/wrapvips7.c index 36c4f419..291f6893 100644 --- a/libvips/deprecated/wrapvips7.c +++ b/libvips/deprecated/wrapvips7.c @@ -123,6 +123,8 @@ typedef enum { VIPS_WRAP7_INTERPOLATE } VipsWrap7Type; +/* Order must match VipsWrap7Type enums. + */ static char *vips_wrap7_supported[] = { IM_TYPE_DOUBLE, IM_TYPE_INT, @@ -537,6 +539,33 @@ vips_wrap7_build_output( VipsObject *object, return( NULL ); } +/* Mark an output as assigned. + */ +static void * +vips_wrap7_note_assigned( VipsObject *object, + GParamSpec *pspec, + VipsArgumentClass *argument_class, + VipsArgumentInstance *argument_instance, + void *a, void *b ) +{ + /* We want required, construct-time, output args. + */ + if( !(argument_class->flags & VIPS_ARGUMENT_REQUIRED) || + !(argument_class->flags & VIPS_ARGUMENT_CONSTRUCT) || + !(argument_class->flags & VIPS_ARGUMENT_OUTPUT) ) + return( NULL ); + + if( !argument_instance->assigned ) { + argument_instance->assigned = TRUE; + + VIPS_DEBUG_MSG( "vips_wrap7_note_assigned: " + "marking %s as assigned\n", + g_param_spec_get_name( pspec ) ); + } + + return( NULL ); +} + static int vips_wrap7_build( VipsObject *object ) { @@ -573,9 +602,21 @@ vips_wrap7_build( VipsObject *object ) if( VIPS_OBJECT_CLASS( vips_wrap7_parent_class )->build( object ) ) return( -1 ); + /* Run the operation. + */ if( class->fn->disp( wrap7->vargv ) ) return( -1 ); + /* The vips7 operation will have written any outputs (such as the + * output double for im_max(), for example) to varg. g_object_get() + * fetches directly from vargv (see vips_wrap7_object_get_property()) + * so we don't need to do any copying, we just need to tell vips that + * all outputs now have values. + */ + (void) vips_argument_map( VIPS_OBJECT( wrap7 ), + vips_wrap7_note_assigned, + NULL, NULL ); + return( 0 ); }