2019-04-24 16:02:52 +02:00
|
|
|
#!/usr/bin/env python
|
2015-01-02 13:39:20 +01:00
|
|
|
|
2019-04-24 16:02:52 +02:00
|
|
|
# walk vips and generate a list of all operators and their descriptions
|
2015-01-02 13:39:20 +01:00
|
|
|
# for docs
|
|
|
|
|
2019-04-24 16:02:52 +02:00
|
|
|
# this needs pyvips
|
|
|
|
#
|
|
|
|
# pip install --user pyvips
|
|
|
|
|
2015-01-02 13:39:20 +01:00
|
|
|
# sample output:
|
|
|
|
|
|
|
|
# <row>
|
|
|
|
# <entry>gamma</entry>
|
2019-04-24 16:02:52 +02:00
|
|
|
# <entry>Gamma an image</entry>
|
2015-01-02 13:39:20 +01:00
|
|
|
# <entry>vips_gamma()</entry>
|
|
|
|
# </row>
|
|
|
|
|
2019-04-24 16:02:52 +02:00
|
|
|
from pyvips import Operation, Error, \
|
|
|
|
ffi, type_map, type_from_name, nickname_find
|
2015-01-02 13:39:20 +01:00
|
|
|
|
2019-04-24 16:02:52 +02:00
|
|
|
# for VipsOperationFlags
|
|
|
|
_OPERATION_DEPRECATED = 8
|
2015-01-02 13:39:20 +01:00
|
|
|
|
|
|
|
|
2019-04-24 16:02:52 +02:00
|
|
|
def gen_function(operation_name):
|
|
|
|
op = Operation.new_from_name(operation_name)
|
2015-01-02 13:39:20 +01:00
|
|
|
|
2019-04-24 16:02:52 +02:00
|
|
|
print('<row>')
|
|
|
|
print(' <entry>{}</entry>'.format(operation_name))
|
|
|
|
print(' <entry>{}</entry>'.format(op.get_description().capitalize()))
|
|
|
|
print(' <entry>vips_{}()</entry>'.format(operation_name))
|
|
|
|
print('</row>')
|
2015-01-02 13:39:20 +01:00
|
|
|
|
|
|
|
|
2019-04-24 16:02:52 +02:00
|
|
|
def gen_function_list():
|
|
|
|
all_nicknames = []
|
2015-01-02 13:39:20 +01:00
|
|
|
|
2019-04-24 16:02:52 +02:00
|
|
|
def add_nickname(gtype, a, b):
|
|
|
|
nickname = nickname_find(gtype)
|
|
|
|
try:
|
|
|
|
# can fail for abstract types
|
|
|
|
op = Operation.new_from_name(nickname)
|
|
|
|
|
|
|
|
# we are only interested in non-deprecated operations
|
|
|
|
if (op.get_flags() & _OPERATION_DEPRECATED) == 0:
|
|
|
|
all_nicknames.append(nickname)
|
|
|
|
except Error:
|
|
|
|
pass
|
|
|
|
|
|
|
|
type_map(gtype, add_nickname)
|
|
|
|
|
|
|
|
return ffi.NULL
|
|
|
|
|
|
|
|
type_map(type_from_name('VipsOperation'), add_nickname)
|
2015-01-02 13:39:20 +01:00
|
|
|
|
2019-04-24 16:02:52 +02:00
|
|
|
# add 'missing' synonyms by hand
|
|
|
|
all_nicknames.append('crop')
|
|
|
|
|
|
|
|
# make list unique and sort
|
|
|
|
all_nicknames = list(set(all_nicknames))
|
|
|
|
all_nicknames.sort()
|
|
|
|
|
|
|
|
for nickname in all_nicknames:
|
|
|
|
gen_function(nickname)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
gen_function_list()
|