missing arguments in text
Using vips text render I am struggling with missing arguments accepted. Sample code
import logging
logging.basicConfig(level = logging.DEBUG)
import pyvips
image = pyvips.Image.text("Puzzling", width=100, height= 150, dpi=300)
image.write_to_file("test.png")
results in
DEBUG:pyvips:Loaded binary module _libvips
DEBUG:pyvips:Module generated for libvips 8.4
DEBUG:pyvips:Linked to libvips 8.4
DEBUG:pyvips:Inited libvips
DEBUG:pyvips.voperation:VipsOperation.call: operation_name = text
DEBUG:pyvips.voperation:VipsOperation.call: string_options =
DEBUG:pyvips.voperation:VipsOperation.call: match_image = None
DEBUG:pyvips.vobject:VipsObject.set: name = text, value = Puzzling
DEBUG:pyvips.vobject:VipsObject.set: name = width, value = 100
DEBUG:pyvips.error:Error text does not support argument height
Traceback (most recent call last):
File "createttftext.py", line 13, in <module>
image = pyvips.Image.text("Puzzling", width=100, height= 150, dpi=300)
File "/home/funky/.local/lib/python3.6/site-packages/pyvips/vimage.py", line 128, in call_function
return pyvips.Operation.call(name, *args, **kwargs)
File "/home/funky/.local/lib/python3.6/site-packages/pyvips/voperation.py", line 208, in call
'{1}'.format(operation_name, name))
pyvips.error.Error: text does not support argument height
I have the same when trying to use font and fontfile in pyvips.image.text while according to https://libvips.github.io/pyvips/vimage.html#pyvips.Image.text these arguments should work. Any idea please ?
Hello @tazzz,
pyvips is a very "thin" wrapper: all it does is expose the features in the underlying libvips library. Support for fitting text into a box was added in 8.6 and I would guess your libvips is older than that.
With libvips 8.8 I see:
$ python3
Python 3.7.3 (default, Apr 3 2019, 05:39:12)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyvips
>>> x = pyvips.Image.text("hello!", width=100, height=150, dpi=300)
>>> x.write_to_file("x.png")
>>>
To make:

Actually, I would write:
x = pyvips.Image.text("hello!", width=100, height=150)
Now it will adjust DPI to try to fill the box. Or do:
x = pyvips.Image.text("hello!", width=100, dpi=300)
And it will render at exactly 300 DPI, wrapping the text at 100px.
Oh, I just noticed, you have:
DEBUG:pyvips:Loaded binary module _libvips
DEBUG:pyvips:Module generated for libvips 8.4
DEBUG:pyvips:Linked to libvips 8.4
DEBUG:pyvips:Inited libvips
So yes, your libvips is from 2016.
The docs for vips_text() explain all the options:
https://libvips.github.io/libvips/API/current/libvips-create.html#vips-text
Should have thought to check the version of the packaged libvips. Ubuntu 18.04 lts ships indeed with libvips 8.4. Building from source and all good now. Thank you!