argh revert the arg order change

we need to patch bindings instead
This commit is contained in:
John Cupitt 2017-03-13 08:24:06 +00:00
parent d854c18a2f
commit 51f96ce9af
9 changed files with 158 additions and 126 deletions

View File

@ -34,9 +34,6 @@
- vips_region_shrink() knows about alpha, helps dzsave and tiffsave
- use expat, not libxml, for XML load ... removes a required dependency, since
we get expat as part of glib
- the C functions vips_math2_const(), vips_boolean_const() and
vips_relational_const() have changed argument order to match
Python/CLI/C++ ... sorry
- added vips_rot90() etc. convenience functions
- fix vips_resize() bug when hscale and vscale were very different

48
TODO
View File

@ -1,3 +1,50 @@
- oh argh, need to swap _const args back
8.4 had:
$ vips relational_const
relational operations against a constant
usage:
relational_const in out relational c
where:
in - Input image, input VipsImage
out - Output image, output VipsImage
relational - relational to perform, input VipsOperationRelational
default: equal
allowed: equal, noteq, less, lesseq, more, moreeq
c - Array of constants, input VipsArrayDouble
operation flags: sequential-unbuffered
$ vips boolean_const
boolean operations against a constant
usage:
boolean_const in out boolean c
where:
in - Input image, input VipsImage
out - Output image, output VipsImage
boolean - boolean to perform, input VipsOperationBoolean
default: and
allowed: and, or, eor, lshift, rshift
c - Array of constants, input VipsArrayDouble
operation flags: sequential-unbuffered
$ vips math2_const
pow( @in, @c )
usage:
math2_const in out math2 c
where:
in - Input image, input VipsImage
out - Output image, output VipsImage
math2 - math to perform, input VipsOperationMath2
default: pow
allowed: pow, wop
c - Array of constants, input VipsArrayDouble
operation flags: sequential-unbuffered
- not sure about utf8 error messages on win
- strange:
@ -421,4 +468,3 @@ new operations
http://www.nature.com/srep/2015/150730/srep12096/full/srep12096.html
sounds useful for BM?

View File

@ -533,7 +533,7 @@ vips_boolean_const_init( VipsBooleanConst *boolean_const )
static int
vips_boolean_constv( VipsImage *in, VipsImage **out,
double *c, int n, VipsOperationBoolean operation, va_list ap )
VipsOperationBoolean operation, double *c, int n, va_list ap )
{
VipsArea *area_c;
double *array;
@ -546,7 +546,7 @@ vips_boolean_constv( VipsImage *in, VipsImage **out,
array[i] = c[i];
result = vips_call_split( "boolean_const", ap,
in, out, area_c, operation );
in, out, operation, area_c );
vips_area_unref( area_c );
@ -557,9 +557,9 @@ vips_boolean_constv( VipsImage *in, VipsImage **out,
* vips_boolean_const:
* @in: input image
* @out: output image
* @boolean: boolean operation to perform
* @c: array of constants
* @n: number of constants in @c
* @boolean: boolean operation to perform
* @...: %NULL-terminated list of optional named arguments
*
* Perform various boolean operations on an image against an array of
@ -580,13 +580,13 @@ vips_boolean_constv( VipsImage *in, VipsImage **out,
*/
int
vips_boolean_const( VipsImage *in, VipsImage **out,
double *c, int n, VipsOperationBoolean boolean, ... )
VipsOperationBoolean boolean, double *c, int n, ... )
{
va_list ap;
int result;
va_start( ap, boolean );
result = vips_boolean_constv( in, out, c, n, boolean, ap );
va_start( ap, n );
result = vips_boolean_constv( in, out, boolean, c, n, ap );
va_end( ap );
return( result );
@ -615,7 +615,7 @@ vips_andimage_const( VipsImage *in, VipsImage **out, double *c, int n, ... )
va_start( ap, n );
result = vips_boolean_constv( in, out,
c, n, VIPS_OPERATION_BOOLEAN_AND, ap );
VIPS_OPERATION_BOOLEAN_AND, c, n, ap );
va_end( ap );
return( result );
@ -644,7 +644,7 @@ vips_orimage_const( VipsImage *in, VipsImage **out, double *c, int n, ... )
va_start( ap, n );
result = vips_boolean_constv( in, out,
c, n, VIPS_OPERATION_BOOLEAN_OR, ap );
VIPS_OPERATION_BOOLEAN_OR, c, n, ap );
va_end( ap );
return( result );
@ -673,7 +673,7 @@ vips_eorimage_const( VipsImage *in, VipsImage **out, double *c, int n, ... )
va_start( ap, n );
result = vips_boolean_constv( in, out,
c, n, VIPS_OPERATION_BOOLEAN_EOR, ap );
VIPS_OPERATION_BOOLEAN_EOR, c, n, ap );
va_end( ap );
return( result );
@ -702,7 +702,7 @@ vips_lshift_const( VipsImage *in, VipsImage **out, double *c, int n, ... )
va_start( ap, n );
result = vips_boolean_constv( in, out,
c, n, VIPS_OPERATION_BOOLEAN_LSHIFT, ap );
VIPS_OPERATION_BOOLEAN_LSHIFT, c, n, ap );
va_end( ap );
return( result );
@ -731,7 +731,7 @@ vips_rshift_const( VipsImage *in, VipsImage **out, double *c, int n, ... )
va_start( ap, n );
result = vips_boolean_constv( in, out,
c, n, VIPS_OPERATION_BOOLEAN_RSHIFT, ap );
VIPS_OPERATION_BOOLEAN_RSHIFT, c, n, ap );
va_end( ap );
return( result );
@ -754,13 +754,13 @@ vips_rshift_const( VipsImage *in, VipsImage **out, double *c, int n, ... )
*/
int
vips_boolean_const1( VipsImage *in, VipsImage **out,
double c, VipsOperationBoolean boolean, ... )
VipsOperationBoolean boolean, double c, ... )
{
va_list ap;
int result;
va_start( ap, boolean );
result = vips_boolean_constv( in, out, &c, 1, boolean, ap );
va_start( ap, c );
result = vips_boolean_constv( in, out, boolean, &c, 1, ap );
va_end( ap );
return( result );
@ -788,7 +788,7 @@ vips_andimage_const1( VipsImage *in, VipsImage **out, double c, ... )
va_start( ap, c );
result = vips_boolean_constv( in, out,
&c, 1, VIPS_OPERATION_BOOLEAN_AND, ap );
VIPS_OPERATION_BOOLEAN_AND, &c, 1, ap );
va_end( ap );
return( result );
@ -816,7 +816,7 @@ vips_orimage_const1( VipsImage *in, VipsImage **out, double c, ... )
va_start( ap, c );
result = vips_boolean_constv( in, out,
&c, 1, VIPS_OPERATION_BOOLEAN_OR, ap );
VIPS_OPERATION_BOOLEAN_OR, &c, 1, ap );
va_end( ap );
return( result );
@ -844,7 +844,7 @@ vips_eorimage_const1( VipsImage *in, VipsImage **out, double c, ... )
va_start( ap, c );
result = vips_boolean_constv( in, out,
&c, 1, VIPS_OPERATION_BOOLEAN_EOR, ap );
VIPS_OPERATION_BOOLEAN_EOR, &c, 1, ap );
va_end( ap );
return( result );
@ -872,7 +872,7 @@ vips_lshift_const1( VipsImage *in, VipsImage **out, double c, ... )
va_start( ap, c );
result = vips_boolean_constv( in, out,
&c, 1, VIPS_OPERATION_BOOLEAN_LSHIFT, ap );
VIPS_OPERATION_BOOLEAN_LSHIFT, &c, 1, ap );
va_end( ap );
return( result );
@ -900,7 +900,7 @@ vips_rshift_const1( VipsImage *in, VipsImage **out, double c, ... )
va_start( ap, c );
result = vips_boolean_constv( in, out,
&c, 1, VIPS_OPERATION_BOOLEAN_RSHIFT, ap );
VIPS_OPERATION_BOOLEAN_RSHIFT, &c, 1, ap );
va_end( ap );
return( result );

View File

@ -421,7 +421,7 @@ vips_math2_const_init( VipsMath2Const *math2_const )
static int
vips_math2_constv( VipsImage *in, VipsImage **out,
double *c, int n, VipsOperationMath2 math2, va_list ap )
VipsOperationMath2 math2, double *c, int n, va_list ap )
{
VipsArea *area_c;
double *array;
@ -433,7 +433,7 @@ vips_math2_constv( VipsImage *in, VipsImage **out,
for( i = 0; i < n; i++ )
array[i] = c[i];
result = vips_call_split( "math2_const", ap, in, out, area_c, math2 );
result = vips_call_split( "math2_const", ap, in, out, math2, area_c );
vips_area_unref( area_c );
@ -444,9 +444,9 @@ vips_math2_constv( VipsImage *in, VipsImage **out,
* vips_math2_const:
* @in: input image
* @out: output image
* @math2: math operation to perform
* @c: array of constants
* @n: number of constants in @c
* @math2: math operation to perform
* @...: %NULL-terminated list of optional named arguments
*
* This operation calculates various 2-ary maths operations on an image and
@ -471,13 +471,13 @@ vips_math2_constv( VipsImage *in, VipsImage **out,
*/
int
vips_math2_const( VipsImage *in, VipsImage **out,
double *c, int n, VipsOperationMath2 math2, ... )
VipsOperationMath2 math2, double *c, int n, ... )
{
va_list ap;
int result;
va_start( ap, math2 );
result = vips_math2_constv( in, out, c, n, math2, ap );
va_start( ap, n );
result = vips_math2_constv( in, out, math2, c, n, ap );
va_end( ap );
return( result );
@ -504,7 +504,7 @@ vips_pow_const( VipsImage *in, VipsImage **out, double *c, int n, ... )
va_start( ap, n );
result = vips_math2_constv( in, out,
c, n, VIPS_OPERATION_MATH2_POW, ap );
VIPS_OPERATION_MATH2_POW, c, n, ap );
va_end( ap );
return( result );
@ -531,7 +531,7 @@ vips_wop_const( VipsImage *in, VipsImage **out, double *c, int n, ... )
va_start( ap, n );
result = vips_math2_constv( in, out,
c, n, VIPS_OPERATION_MATH2_WOP, ap );
VIPS_OPERATION_MATH2_WOP, c, n, ap );
va_end( ap );
return( result );
@ -552,13 +552,13 @@ vips_wop_const( VipsImage *in, VipsImage **out, double *c, int n, ... )
*/
int
vips_math2_const1( VipsImage *in, VipsImage **out,
double c, VipsOperationMath2 math2, ... )
VipsOperationMath2 math2, double c, ... )
{
va_list ap;
int result;
va_start( ap, math2 );
result = vips_math2_constv( in, out, &c, 1, math2, ap );
va_start( ap, c );
result = vips_math2_constv( in, out, math2, &c, 1, ap );
va_end( ap );
return( result );
@ -584,7 +584,7 @@ vips_pow_const1( VipsImage *in, VipsImage **out, double c, ... )
va_start( ap, c );
result = vips_math2_constv( in, out,
&c, 1, VIPS_OPERATION_MATH2_POW, ap );
VIPS_OPERATION_MATH2_POW, &c, 1, ap );
va_end( ap );
return( result );
@ -610,7 +610,7 @@ vips_wop_const1( VipsImage *in, VipsImage **out, double c, ... )
va_start( ap, c );
result = vips_math2_constv( in, out,
&c, 1, VIPS_OPERATION_MATH2_WOP, ap );
VIPS_OPERATION_MATH2_WOP, &c, 1, ap );
va_end( ap );
return( result );

View File

@ -574,7 +574,7 @@ vips_relational_const_init( VipsRelationalConst *relational_const )
static int
vips_relational_constv( VipsImage *in, VipsImage **out,
double *c, int n, VipsOperationRelational relational, va_list ap )
VipsOperationRelational relational, double *c, int n, va_list ap )
{
VipsArea *area_c;
double *array;
@ -587,7 +587,7 @@ vips_relational_constv( VipsImage *in, VipsImage **out,
array[i] = c[i];
result = vips_call_split( "relational_const", ap,
in, out, area_c, relational );
in, out, relational, area_c );
vips_area_unref( area_c );
@ -598,9 +598,9 @@ vips_relational_constv( VipsImage *in, VipsImage **out,
* vips_relational_const:
* @in: input image
* @out: output image
* @relational: relational operation to perform
* @c: array of constants
* @n: number of constants in @c
* @relational: relational operation to perform
* @...: %NULL-terminated list of optional named arguments
*
* Perform various relational operations on an image and an array of
@ -621,13 +621,13 @@ vips_relational_constv( VipsImage *in, VipsImage **out,
*/
int
vips_relational_const( VipsImage *in, VipsImage **out,
double *c, int n, VipsOperationRelational relational, ... )
VipsOperationRelational relational, double *c, int n, ... )
{
va_list ap;
int result;
va_start( ap, relational );
result = vips_relational_constv( in, out, c, n, relational, ap );
va_start( ap, n );
result = vips_relational_constv( in, out, relational, c, n, ap );
va_end( ap );
return( result );
@ -654,7 +654,7 @@ vips_equal_const( VipsImage *in, VipsImage **out, double *c, int n, ... )
va_start( ap, n );
result = vips_relational_constv( in, out,
c, n, VIPS_OPERATION_RELATIONAL_EQUAL, ap );
VIPS_OPERATION_RELATIONAL_EQUAL, c, n, ap );
va_end( ap );
return( result );
@ -681,7 +681,7 @@ vips_notequal_const( VipsImage *in, VipsImage **out, double *c, int n, ... )
va_start( ap, n );
result = vips_relational_constv( in, out,
c, n, VIPS_OPERATION_RELATIONAL_NOTEQ, ap );
VIPS_OPERATION_RELATIONAL_NOTEQ, c, n, ap );
va_end( ap );
return( result );
@ -708,7 +708,7 @@ vips_less_const( VipsImage *in, VipsImage **out, double *c, int n, ... )
va_start( ap, n );
result = vips_relational_constv( in, out,
c, n, VIPS_OPERATION_RELATIONAL_LESS, ap );
VIPS_OPERATION_RELATIONAL_LESS, c, n, ap );
va_end( ap );
return( result );
@ -735,7 +735,7 @@ vips_lesseq_const( VipsImage *in, VipsImage **out, double *c, int n, ... )
va_start( ap, n );
result = vips_relational_constv( in, out,
c, n, VIPS_OPERATION_RELATIONAL_LESSEQ, ap );
VIPS_OPERATION_RELATIONAL_LESSEQ, c, n, ap );
va_end( ap );
return( result );
@ -762,7 +762,7 @@ vips_more_const( VipsImage *in, VipsImage **out, double *c, int n, ... )
va_start( ap, n );
result = vips_relational_constv( in, out,
c, n, VIPS_OPERATION_RELATIONAL_MORE, ap );
VIPS_OPERATION_RELATIONAL_MORE, c, n, ap );
va_end( ap );
return( result );
@ -789,7 +789,7 @@ vips_moreeq_const( VipsImage *in, VipsImage **out, double *c, int n, ... )
va_start( ap, n );
result = vips_relational_constv( in, out,
c, n, VIPS_OPERATION_RELATIONAL_MOREEQ, ap );
VIPS_OPERATION_RELATIONAL_MOREEQ, c, n, ap );
va_end( ap );
return( result );
@ -799,8 +799,8 @@ vips_moreeq_const( VipsImage *in, VipsImage **out, double *c, int n, ... )
* vips_relational_const1:
* @in: input image
* @out: output image
* @c: constant
* @relational: relational operation to perform
* @c: constant
* @...: %NULL-terminated list of optional named arguments
*
* Perform various relational operations on an image and a constant. See
@ -812,13 +812,13 @@ vips_moreeq_const( VipsImage *in, VipsImage **out, double *c, int n, ... )
*/
int
vips_relational_const1( VipsImage *in, VipsImage **out,
double c, VipsOperationRelational relational, ... )
VipsOperationRelational relational, double c, ... )
{
va_list ap;
int result;
va_start( ap, relational );
result = vips_relational_constv( in, out, &c, 1, relational, ap );
va_start( ap, c );
result = vips_relational_constv( in, out, relational, &c, 1, ap );
va_end( ap );
return( result );
@ -844,7 +844,7 @@ vips_equal_const1( VipsImage *in, VipsImage **out, double c, ... )
va_start( ap, c );
result = vips_relational_constv( in, out,
&c, 1, VIPS_OPERATION_RELATIONAL_EQUAL, ap );
VIPS_OPERATION_RELATIONAL_EQUAL, &c, 1, ap );
va_end( ap );
return( result );
@ -870,7 +870,7 @@ vips_notequal_const1( VipsImage *in, VipsImage **out, double c, ... )
va_start( ap, c );
result = vips_relational_constv( in, out,
&c, 1, VIPS_OPERATION_RELATIONAL_NOTEQ, ap );
VIPS_OPERATION_RELATIONAL_NOTEQ, &c, 1, ap );
va_end( ap );
return( result );
@ -896,7 +896,7 @@ vips_less_const1( VipsImage *in, VipsImage **out, double c, ... )
va_start( ap, c );
result = vips_relational_constv( in, out,
&c, 1, VIPS_OPERATION_RELATIONAL_LESS, ap );
VIPS_OPERATION_RELATIONAL_LESS, &c, 1, ap );
va_end( ap );
return( result );
@ -922,7 +922,7 @@ vips_lesseq_const1( VipsImage *in, VipsImage **out, double c, ... )
va_start( ap, c );
result = vips_relational_constv( in, out,
&c, 1, VIPS_OPERATION_RELATIONAL_LESSEQ, ap );
VIPS_OPERATION_RELATIONAL_LESSEQ, &c, 1, ap );
va_end( ap );
return( result );
@ -948,7 +948,7 @@ vips_more_const1( VipsImage *in, VipsImage **out, double c, ... )
va_start( ap, c );
result = vips_relational_constv( in, out,
&c, 1, VIPS_OPERATION_RELATIONAL_MORE, ap );
VIPS_OPERATION_RELATIONAL_MORE, &c, 1, ap );
va_end( ap );
return( result );
@ -974,7 +974,7 @@ vips_moreeq_const1( VipsImage *in, VipsImage **out, double c, ... )
va_start( ap, c );
result = vips_relational_constv( in, out,
&c, 1, VIPS_OPERATION_RELATIONAL_MOREEQ, ap );
VIPS_OPERATION_RELATIONAL_MOREEQ, &c, 1, ap );
va_end( ap );
return( result );

View File

@ -203,7 +203,7 @@ vips_unary_const_class_init( VipsUnaryConstClass *class )
object_class->description = _( "unary operations with a constant" );
object_class->build = vips_unary_const_build;
VIPS_ARG_BOXED( class, "c", 199,
VIPS_ARG_BOXED( class, "c", 201,
_( "c" ),
_( "Array of constants" ),
VIPS_ARGUMENT_REQUIRED_INPUT,

View File

@ -2749,7 +2749,7 @@ vips__relational_vec( IMAGE *in, IMAGE *out,
{
VipsImage *t;
if( vips_relational_const( in, &t, c, n, relational,
if( vips_relational_const( in, &t, relational, c, n,
NULL ) )
return( -1 );
if( vips_image_write( t, out ) ) {
@ -2921,7 +2921,7 @@ vips__boolean_vec( IMAGE *in, IMAGE *out,
{
VipsImage *t;
if( vips_boolean_const( in, &t, c, n, boolean,
if( vips_boolean_const( in, &t, boolean, c, n,
NULL ) )
return( -1 );
if( vips_image_write( t, out ) ) {
@ -3008,7 +3008,7 @@ vips__math2_vec( IMAGE *in, IMAGE *out,
{
VipsImage *t;
if( vips_math2_const( in, &t, c, n, math2,
if( vips_math2_const( in, &t, math2, c, n,
NULL ) )
return( -1 );
if( vips_image_write( t, out ) ) {

View File

@ -279,7 +279,7 @@ int vips_more( VipsImage *left, VipsImage *right, VipsImage **out, ... )
int vips_moreeq( VipsImage *left, VipsImage *right, VipsImage **out, ... )
__attribute__((sentinel));
int vips_relational_const( VipsImage *in, VipsImage **out,
double *c, int n, VipsOperationRelational relational, ... )
VipsOperationRelational relational, double *c, int n, ... )
__attribute__((sentinel));
int vips_equal_const( VipsImage *in, VipsImage **out, double *c, int n, ... )
__attribute__((sentinel));
@ -294,7 +294,7 @@ int vips_more_const( VipsImage *in, VipsImage **out, double *c, int n, ... )
int vips_moreeq_const( VipsImage *in, VipsImage **out, double *c, int n, ... )
__attribute__((sentinel));
int vips_relational_const1( VipsImage *in, VipsImage **out,
double c, VipsOperationRelational relational, ... )
VipsOperationRelational relational, double c, ... )
__attribute__((sentinel));
int vips_equal_const1( VipsImage *in, VipsImage **out, double c, ... )
__attribute__((sentinel));
@ -324,7 +324,7 @@ int vips_rshift( VipsImage *left, VipsImage *right, VipsImage **out, ... )
__attribute__((sentinel));
int vips_boolean_const( VipsImage *in, VipsImage **out,
double *c, int n, VipsOperationBoolean boolean, ... )
VipsOperationBoolean boolean, double *c, int n, ... )
__attribute__((sentinel));
int vips_andimage_const( VipsImage *in, VipsImage **out, double *c, int n, ... )
__attribute__((sentinel));
@ -337,7 +337,7 @@ int vips_lshift_const( VipsImage *in, VipsImage **out, double *c, int n, ... )
int vips_rshift_const( VipsImage *in, VipsImage **out, double *c, int n, ... )
__attribute__((sentinel));
int vips_boolean_const1( VipsImage *in, VipsImage **out,
double c, VipsOperationBoolean boolean, ... )
VipsOperationBoolean boolean, double c, ... )
__attribute__((sentinel));
int vips_andimage_const1( VipsImage *in, VipsImage **out, double c, ... )
__attribute__((sentinel));
@ -358,14 +358,14 @@ int vips_pow( VipsImage *left, VipsImage *right, VipsImage **out, ... )
int vips_wop( VipsImage *left, VipsImage *right, VipsImage **out, ... )
__attribute__((sentinel));
int vips_math2_const( VipsImage *in, VipsImage **out,
double *c, int n, VipsOperationMath2 math2, ... )
VipsOperationMath2 math2, double *c, int n, ... )
__attribute__((sentinel));
int vips_pow_const( VipsImage *in, VipsImage **out, double *c, int n, ... )
__attribute__((sentinel));
int vips_wop_const( VipsImage *in, VipsImage **out, double *c, int n, ... )
__attribute__((sentinel));
int vips_math2_const1( VipsImage *in, VipsImage **out,
double c, VipsOperationMath2 math2, ... )
VipsOperationMath2 math2, double c, ... )
__attribute__((sentinel));
int vips_pow_const1( VipsImage *in, VipsImage **out, double c, ... )
__attribute__((sentinel));

View File

@ -60,6 +60,11 @@ vips_type_image = GObject.GType.from_name("VipsImage")
vips_type_operation = GObject.GType.from_name("VipsOperation")
vips_type_ref_string = GObject.GType.from_name("VipsRefString")
# 8.4 and earlier had a bug which swapped the order of const args to enum
# operations
swap_const_args = Vips.version(0) < 8 or (Vips.version(0) == 8 and
Vips.version(1) <= 4)
def is_2D(value):
if not isinstance(value, list):
return False
@ -415,6 +420,27 @@ def _call_base(name, required, optional, self = None, option_string = None):
return out
# handy for expanding enums
def _call_enum(self, name, enum, other):
if isinstance(other, Vips.Image):
return _call_base(name, [other, enum], {}, self)
elif swap_const_args:
return _call_base(name + "_const", [other, enum], {}, self)
else:
return _call_base(name + "_const", [enum, other], {}, self)
# for equality style operations, we need to allow comparison with None
def _call_enum_eq(self, name, enum, other):
if isinstance(other, Vips.Image):
return _call_base(name, [other, enum], {}, self)
elif isinstance(other, list) or isinstance(other, numbers.Number):
if swap_const_args:
return _call_base(name + "_const", [other, enum], {}, self)
else:
return _call_base(name + "_const", [enum, other], {}, self)
else:
return False
# general user entrypoint
def call(name, *args, **kwargs):
return _call_base(name, args, kwargs)
@ -712,52 +738,34 @@ class Image(Vips.Image):
return self.remainder_const(other)
def __pow__(self, other):
if isinstance(other, Vips.Image):
return self.math2(other, Vips.OperationMath2.POW)
else:
return self.math2_const(other, Vips.OperationMath2.POW)
return _call_enum(self, "math2", Vips.OperationMath2.POW, other)
def __rpow__(self, other):
return self.math2_const(other, Vips.OperationMath2.WOP)
return _call_enum(self, "math2", Vips.OperationMath2.WOP, other)
def __abs__(self):
return self.abs()
def __lshift__(self, other):
if isinstance(other, Vips.Image):
return self.boolean(other, Vips.OperationBoolean.LSHIFT)
else:
return self.boolean_const(other, Vips.OperationBoolean.LSHIFT)
return _call_enum(self, "boolean", Vips.OperationBoolean.LSHIFT, other)
def __rshift__(self, other):
if isinstance(other, Vips.Image):
return self.boolean(other, Vips.OperationBoolean.RSHIFT)
else:
return self.boolean_const(other, Vips.OperationBoolean.RSHIFT)
return _call_enum(self, "boolean", Vips.OperationBoolean.RSHIFT, other)
def __and__(self, other):
if isinstance(other, Vips.Image):
return self.boolean(other, Vips.OperationBoolean.AND)
else:
return self.boolean_const(other, Vips.OperationBoolean.AND)
return _call_enum(self, "boolean", Vips.OperationBoolean.AND, other)
def __rand__(self, other):
return self.__and__(other)
def __or__(self, other):
if isinstance(other, Vips.Image):
return self.boolean(other, Vips.OperationBoolean.OR)
else:
return self.boolean_const(other, Vips.OperationBoolean.OR)
return _call_enum(self, "boolean", Vips.OperationBoolean.OR, other)
def __ror__(self, other):
return self.__or__(other)
def __xor__(self, other):
if isinstance(other, Vips.Image):
return self.boolean(other, Vips.OperationBoolean.EOR)
else:
return self.boolean_const(other, Vips.OperationBoolean.EOR)
return _call_enum(self, "boolean", Vips.OperationBoolean.EOR, other)
def __rxor__(self, other):
return self.__xor__(other)
@ -772,49 +780,30 @@ class Image(Vips.Image):
return self ^ -1
def __gt__(self, other):
if isinstance(other, Vips.Image):
return self.relational(other, Vips.OperationRelational.MORE)
else:
return self.relational_const(other, Vips.OperationRelational.MORE)
return _call_enum(self,
"relational", Vips.OperationRelational.MORE, other)
def __ge__(self, other):
if isinstance(other, Vips.Image):
return self.relational(other, Vips.OperationRelational.MOREEQ)
else:
return self.relational_const(other, Vips.OperationRelational.MOREEQ)
return _call_enum(self,
"relational", Vips.OperationRelational.MOREEQ, other)
def __lt__(self, other):
if isinstance(other, Vips.Image):
return self.relational(other, Vips.OperationRelational.LESS)
else:
return self.relational_const(other, Vips.OperationRelational.LESS)
return _call_enum(self,
"relational", Vips.OperationRelational.LESS, other)
def __le__(self, other):
if isinstance(other, Vips.Image):
return self.relational(other, Vips.OperationRelational.LESSEQ)
else:
return self.relational_const(other, Vips.OperationRelational.LESSEQ)
return _call_enum(self,
"relational", Vips.OperationRelational.LESSEQ, other)
def __eq__(self, other):
# for == and != we need to allow comparison to None
if isinstance(other, Vips.Image):
return self.relational(other, Vips.OperationRelational.EQUAL)
elif isinstance(other, list):
return self.relational_const(other, Vips.OperationRelational.EQUAL)
elif isinstance(other, numbers.Number):
return self.relational_const(other, Vips.OperationRelational.EQUAL)
else:
return False
# _eq version allows comparison to None
return _call_enum_eq(self,
"relational", Vips.OperationRelational.EQUAL, other)
def __ne__(self, other):
if isinstance(other, Vips.Image):
return self.relational(other, Vips.OperationRelational.NOTEQ)
elif isinstance(other, list):
return self.relational_const(other, Vips.OperationRelational.NOTEQ)
elif isinstance(other, numbers.Number):
return self.relational_const(other, Vips.OperationRelational.NOTEQ)
else:
return False
# _eq version allows comparison to None
return _call_enum_eq(self,
"relational", Vips.OperationRelational.NOTEQ, other)
def __getitem__(self, arg):
if isinstance(arg, slice):