From 11b136b2df92335e6e2b26e01f16a4b0a7bda39f Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Fri, 17 Jun 2016 11:27:13 +0100 Subject: [PATCH] pyvips8 can create new metadata previously it tried to lookup the type of the field in set(), now if OK if there's no field there already --- ChangeLog | 1 + TODO | 6 ------ python/packages/gi/overrides/Vips.py | 22 ++++++++++++---------- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index 03f0ae14..6f6e8f90 100644 --- a/ChangeLog +++ b/ChangeLog @@ -25,6 +25,7 @@ - VImage::ifthenelse() with double args was missing =0 on options - better accuracy for reducev with smarter multiplication - better quality for vips_resize() with linear/cubic kernels +- pyvips8 can create new metadata 18/5/16 started 8.3.2 - more robust vips image reading diff --git a/TODO b/TODO index 03de27da..78ccb86f 100644 --- a/TODO +++ b/TODO @@ -1,9 +1,3 @@ -- python can't set new metadata, it can only set existing metadata - - im.set_value("banana", 12) - - will fail as Vips.py tries to look up the type of "banana" - - add more webp tests to py suite - try moving some more of the CLI tests to py diff --git a/python/packages/gi/overrides/Vips.py b/python/packages/gi/overrides/Vips.py index 7363a6d6..6961b839 100644 --- a/python/packages/gi/overrides/Vips.py +++ b/python/packages/gi/overrides/Vips.py @@ -872,18 +872,20 @@ class Image(Vips.Image): logger.debug('%s.%s = %s' % (self, field, value)) logger.debug('%s.%s needs a %s' % (self, field, gtype)) - # blob-ize - if GObject.type_is_a(gtype, vips_type_blob): - if not isinstance(value, Vips.Blob): - value = Vips.Blob.new(None, value) + # there must be a better way to test for GType(0) + if gtype.name != 'invalid': + # blob-ize + if GObject.type_is_a(gtype, vips_type_blob): + if not isinstance(value, Vips.Blob): + value = Vips.Blob.new(None, value) - # image-ize - if GObject.type_is_a(gtype, vips_type_image): - if not isinstance(value, Vips.Image): - value = imageize(self, value) + # image-ize + if GObject.type_is_a(gtype, vips_type_image): + if not isinstance(value, Vips.Image): + value = imageize(self, value) - # array-ize some types, if necessary - value = arrayize(gtype, value) + # array-ize some types, if necessary + value = arrayize(gtype, value) self.set(field, value)