harvard-lts / kakadu-vips

Kakadu JP2 reader and writer for libvips
Apache License 2.0
3 stars 0 forks source link

Register `jph` format handle #6

Closed scossu closed 5 months ago

scossu commented 6 months ago
>>> with open("/data/pytest.jp2", "rb") as fh:
>>>     img = Image.new_from_buffer(fh.read(), options="")
>>> buf = img.write_to_buffer(".jph")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.11/dist-packages/pyvips/vimage.py", line 864, in write_to_buffer
    raise Error('unable to write to buffer')
pyvips.error.Error: unable to write to buffer
  VipsForeignSave: ".jph" is not a known buffer format

Should the jph extension be registered as a buffer format for saving with kakadusave?

My goal here is to write a general-purpose conversion function that defers to the output format for choosing the saver.

jcupitt commented 5 months ago

Hi again @scossu,

The saver only supports jp2 right now, so no jpx or jph.

I'll have a look at enabling jph support, I've no idea how tricky/easy it is.

jcupitt commented 5 months ago

It was pretty simple (phew). Let's move any discussion to the PR.