Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add htj2k option #9

Merged
merged 3 commits into from
Mar 5, 2024
Merged

add htj2k option #9

merged 3 commits into from
Mar 5, 2024

Conversation

jcupitt
Copy link
Collaborator

@jcupitt jcupitt commented Mar 5, 2024

to enable high-throughput j2k

see #6

to enable high-throughput j2k

see #6
@jcupitt
Copy link
Collaborator Author

jcupitt commented Mar 5, 2024

Test with eg.:

$ time vips kakadusave k2.jpg x.jp2 --options Creversible=yes

real	0m0.091s
user	0m0.462s
sys	0m0.020s
$ time vips kakadusave k2.jpg x.jph --options Creversible=yes

real	0m0.080s
user	0m0.090s
sys	0m0.037s
$ ls -l x.jp2 x.jph
-rw-r--r-- 1 john john 2447603 Mar  5 18:29 x.jp2
-rw-r--r-- 1 john john 2681043 Mar  5 18:29 x.jph

You can see there's a dramatic drop in user time, and the file size is slightly larger.

The option is enabled automatically for filenames with a .jph suffix, or you can set the htj2k option if there's no filename available.

data = image.kakadusave_buffer(htj2k=True)

@scossu
Copy link
Collaborator

scossu commented Mar 5, 2024

pyvips is still not detecting the extension:

>>> from pyvips import Image
>>> img = Image.new_from_file("x.jph")
>>> img.get("vips-loader")
'jp2kload'
>>> with open("x.jph", "rb") as fh:
...     img = Image.new_from_buffer(fh.read(), options="")
... 
>>> img.get("vips-loader")
'jp2kload_buffer'

Shouldn't the loader be kakaduload and kakaduload_buffer respectively?

@jcupitt
Copy link
Collaborator Author

jcupitt commented Mar 5, 2024

The kakadu loader and saver don't take over libvips jpeg2000 handling, you have to invoke them explicitly with kakaduload and kakadusave.

@scossu
Copy link
Collaborator

scossu commented Mar 5, 2024

OK, got it. My impression was that they would (as OPJ does, or doesn't it either?)

In either case it's not a big deal, I'll just add a fallback option.

@scossu
Copy link
Collaborator

scossu commented Mar 5, 2024

Could you please look into the merge conflicts? I think I could resolve them but I'd rather rely on your judgment.

@jcupitt
Copy link
Collaborator Author

jcupitt commented Mar 5, 2024

We could make them take over all jpeg2000 handling, but that should probably be another PR.

@jcupitt jcupitt merged commit 6496f37 into main Mar 5, 2024
@scossu
Copy link
Collaborator

scossu commented Mar 5, 2024

That would be ideal, thanks.

@scossu scossu deleted the add-htj2k branch March 5, 2024 22:12
@jcupitt
Copy link
Collaborator Author

jcupitt commented Mar 5, 2024

OK, I made #10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants