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

Usage question -- Getting access to the in-memory representation of the compressed data #164

Closed
hmaarrfk opened this issue Dec 29, 2024 · 5 comments

Comments

@hmaarrfk
Copy link

Happy new year!

Thank you for the great work! I've been testing this library and I find it quite compelling.

I actually managed to write some python wrappers to help me better benchmark things when compared to other compression options.

I was wondering if there was a way to get access to the "binary data" that we must dump to a tiff in order to make this "compliant" with OpenJPEG'ed compressed TIFF page.

I know you are working with openjpeg to do this uclouvain/openjpeg#1487

however, while waiting, is there a way to access the "compressed data" and the "required headers" as data pointers for us to write to a file (or memory bufffer) ourselves?

I hope this question makes sense.

Best,

Mark

@hmaarrfk
Copy link
Author

For example, for the "decompression path" i found the line interface of codestream.pull

https://github.com/ramonaoptics/ojph/blob/main/ojph/_imread.py#L96

@aous72
Copy link
Owner

aous72 commented Dec 30, 2024

Hi Mark,

Happy holiday season!
Glad you found the library useful.

I am a bit confused about the question.
I think you are asking if you can compress an image into a memory file.
The answer is yes. You can use ojph::mem_outfile

class OJPH_EXPORT mem_outfile : public outfile_base

Then you use the created object as an output file for compression, using it in codestream.write_headers().
Then you can access the compressed data from this memory file, copy it somewhere else, or write it to a file.

Alternatively, you can use develop a derived class/object from ojph::outfile_base, and use it, where ojph::mem_outfile serves as an example implementation, as Chris Hafey is doing in https://github.com/chafey/openjphjs/blob/master/src/EncodedBuffer.hpp

Does that answer the question? please let me know.

@hmaarrfk
Copy link
Author

I think this answers my question. I'll have to study it in a bit more depth. I had a hunch that this is what I was supposed to look for but I wasn't sure.

As a followup question. do you know if this is "in memory file" is what I need to dump to a TIFF page in order for readers to open it correctly?

Do you know of a TIFF reader that can open OpenJPEG files that I could test my writer against?

@aous72
Copy link
Owner

aous72 commented Dec 30, 2024

I am not familiar with TIFF pages, and TIFF in general.
I am sorry I cannot help in this regard.

@hmaarrfk
Copy link
Author

Alright, thank you so much already, i'll close this and maybe reopen or get in touch again if I have new questions.

Happy new year!!!

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

No branches or pull requests

2 participants