fix up ifthenelse and set_value
This commit is contained in:
parent
fc4c8b9cd7
commit
a8f4ed7871
11
TODO
11
TODO
@ -1,17 +1,8 @@
|
|||||||
|
|
||||||
- python:
|
- python:
|
||||||
|
|
||||||
- constants for images:
|
- update examples with new image constant rules
|
||||||
|
|
||||||
- support a.set_value('x', 2), where 'x' is an image arg, or
|
|
||||||
an imagearray arg
|
|
||||||
|
|
||||||
- c.ifthenelse(t, e) ... if t or e are constants, we need to
|
|
||||||
match to the other branch of the conditional, not to the
|
|
||||||
constant
|
|
||||||
|
|
||||||
maybe match to the constant if both t and e are numbers
|
|
||||||
|
|
||||||
- do more tests
|
- do more tests
|
||||||
|
|
||||||
- put exif autorotate into jpeg load
|
- put exif autorotate into jpeg load
|
||||||
|
@ -590,14 +590,19 @@ class Image(Vips.Image):
|
|||||||
logging.debug('assigning %s to %s' % (value, self))
|
logging.debug('assigning %s to %s' % (value, self))
|
||||||
logging.debug('%s needs a %s' % (self, gtype))
|
logging.debug('%s needs a %s' % (self, gtype))
|
||||||
|
|
||||||
# array-ize some types, if necessary
|
|
||||||
value = arrayize(gtype, value)
|
|
||||||
|
|
||||||
# blob-ize
|
# blob-ize
|
||||||
if GObject.type_is_a(gtype, vips_type_blob):
|
if GObject.type_is_a(gtype, vips_type_blob):
|
||||||
if not isinstance(value, Vips.Blob):
|
if not isinstance(value, Vips.Blob):
|
||||||
value = Vips.Blob.new(None, value)
|
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(match_image, value)
|
||||||
|
|
||||||
|
# array-ize some types, if necessary
|
||||||
|
value = arrayize(gtype, value)
|
||||||
|
|
||||||
self.set(field, value)
|
self.set(field, value)
|
||||||
|
|
||||||
def floor(self):
|
def floor(self):
|
||||||
@ -675,6 +680,20 @@ class Image(Vips.Image):
|
|||||||
def exp10(self):
|
def exp10(self):
|
||||||
return self.math(Vips.OperationMath.EXP10)
|
return self.math(Vips.OperationMath.EXP10)
|
||||||
|
|
||||||
|
# we need different imageize rules for this operator ... we need to
|
||||||
|
# imageize th and el to match each other first
|
||||||
|
def ifthenelse(self, th, el, **kwargs):
|
||||||
|
for match_image in [th, el, self]:
|
||||||
|
if isinstance(match_image, Vips.Image):
|
||||||
|
break
|
||||||
|
|
||||||
|
if not isinstance(th, Vips.Image):
|
||||||
|
th = imageize(match_image, th)
|
||||||
|
if not isinstance(el, Vips.Image):
|
||||||
|
el = imageize(match_image, el)
|
||||||
|
|
||||||
|
return _call_base("ifthenelse", [th, el], kwargs, self)
|
||||||
|
|
||||||
# add operators which needs to be class methods
|
# add operators which needs to be class methods
|
||||||
|
|
||||||
# use find_class_methods.py to generate this list
|
# use find_class_methods.py to generate this list
|
||||||
|
@ -11,3 +11,9 @@ a = Vips.Image.black(100, 100)
|
|||||||
b = a.bandjoin(2)
|
b = a.bandjoin(2)
|
||||||
|
|
||||||
b.write_to_file("x.v")
|
b.write_to_file("x.v")
|
||||||
|
|
||||||
|
txt = Vips.Image.text("left corner", dpi = 300)
|
||||||
|
|
||||||
|
c = txt.ifthenelse(2, [0, 255, 0], blend = True)
|
||||||
|
|
||||||
|
c.write_to_file("x2.v")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user