Open lchunleo opened 1 year ago
Hi @lchunleo,
Sure, eg.:
$ python3
Python 3.10.7 (main, Mar 10 2023, 10:47:39) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyvips
>>> x = pyvips.Image.new_from_file("x.avif")
>>> numpy_array = x.numpy()
Then to save again:
>>> y = pyvips.Image.new_from_array(numpy_array)
>>> y.write_to_file("y.avif")
>>>
There are some options to control the process, see the docs.
https://www.libvips.org/API/current/VipsForeignSave.html#vips-heifload
https://www.libvips.org/API/current/VipsForeignSave.html#vips-heifsave
Also, setting access="sequential"
on new_from_file()
can help lower memory use if all you're doing is converting to numpy.
Hi
i wish to know is it possible to 1) Convert numpy to Avif format 2) Convert Avif back to numpy
Would appreciate if there is some examples how to do so in python. Thanks