harvard-lts / kakadu-vips

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

kakadusave: implement `ORGgen_tlm=<n>` #5

Closed scossu closed 5 months ago

scossu commented 6 months ago
>>> img.kakadusave("/data/pytest.jpx", options="Qfactor=90 Cmodes=HT ORGgen_plt=yes Creversible=no Cblk={64,64} ORGtparts=R OGgen_tlm=9")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.11/dist-packages/pyvips/vimage.py", line 1347, in call_function
    return pyvips.Operation.call(name, self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/pyvips/voperation.py", line 305, in call
    raise Error('unable to call {0}'.format(operation_name))
pyvips.error.Error: unable to call kakadusave
  kakadusave: unable to set option OGgen_tlm=9
scossu commented 6 months ago

Never mind. My typo.

scossu commented 6 months ago

However:

>>> img.kakadusave("/data/pytest.jpx", options="Qfactor=90 Cmodes=HT ORGgen_plt=yes Creversible=no Cblk={64,64} ORGtparts=R ORGgen_tlm=9
")

** (process:598): WARNING **: 10:48:30.503: Kakadu Core Warning:
The `Qweights' parameter values supplied are not a close match to the
square-root of the synthesis energy gains of the prevailing multi-component
transform, if any, in tile 0.  Use the following parameters: 1.732051,
1.805108, 1.573402.

** (process:598): WARNING **: 10:48:30.517: Kakadu Core Warning:
Unable to generate the TLM marker segments requested via the `ORGgen_tlm'
parameter attribute.  The reason for this is that the logical compressed data
target supplied by the application does not appear to support rewriting (i.e.,
seeking).  We need this to reserve space for the TLM marker segments up front
and later overwrite the reserved space with valid tile-part lengths.

The image gets created, with the above warnings. img was created with a simple Image.kakaduload(). Is there anything that needs to be set up to create tile-length main markers?

jcupitt commented 5 months ago

Hi again,

Yes, the kdu_compressed_target class in kakadusave does not implement seek:

https://github.com/harvard-lts/kakadu-vips/blob/main/src/kakadusave.cpp#L24-L95

Only open/write/close. I didn't realise seek was required for some kakadu features. I'll make a PR to add seek support.

jcupitt commented 5 months ago

I made a PR to fix this: https://github.com/harvard-lts/kakadu-vips/pull/8

Let's continue any discussion there.