-
Notifications
You must be signed in to change notification settings - Fork 80
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
Tiff encoding #23
Tiff encoding #23
Conversation
I have now made some improvements to the encoder api and the above could now be written as: let file = std::fs::File::create("test.tiff").unwrap();
let mut tiff = TiffEncoder::new(file).unwrap();
let mut image = tiff.new_image::<RGB8>(100, 100).unwrap();
let mut idx = 0;
while image.next_strip_sample_count() > 0 {
let sample_count = image.next_strip_sample_count() as usize;
image.write_strip(&image_data[idx..idx+sample_count]).unwrap();
idx += sample_count;
}
image.finish().unwrap(); Currently I have created two apis, one low level and one semi-high level. I think that after a simple clean-up and some documentation this patch should be ready. |
Thank you for your work on this! I'll look a quick look at it now and one more when you think it's finished. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aside from the TODOs and lack of docs, looks good! More tests would be nice but that can always be added later.
Also, I noticed a few new compiler and clippy warnings, please try to fix these.
@Robzz I think I have fixed most of your concerns, however I have two concerns myself that I would like you to comment on before I am happy with the result. The first is that I have used quite a bit of associated constants and the image crate has rust 1.24.1 as minimum supported version. I am not entirely sure if rust 1.24 supports them, should I simply use methods instead? On a related note I have used a lot of traits to control decoding. I think the If you do not think that these are big issues that I would say that this PR is finished. |
Regarding associated constants, they were stabilized in rust 1.20 so compatibility with the image crate is ok. It might be a good idea to specify the version requirement in the README though. I'll take a deeper look in the next few days with the TIFF spec my by side and play with it a bit. |
A few things i have noted when using this:
|
Hey, I still haven't looked at it in depth but I haven't forgotten, it's planned for this week end ;) Adressing your points in order:
|
I'm mostly done reading the code, looks good to me. I'll still have to play with it a bit, I'll let you know if I run into any issues. |
On more thing that I have noticed is that there maybe should be some more convenience methods on |
@Robzz I have done some small fixes and I think all of your points are covered. Please let me know if there is anything more you would like me to do. |
I reviewed your latest commit, everything looks good to me. I'm for merging this, problems we encounter we can fix later, an we'll certainly get more feedback from people trying to use this than you'll get from me in this PR. However, I don't have merge powers 'round here. @bvssvni (or anyone else with magic merge powers) could you please give it a look and merge if OK ? |
There's nothing major, but the part about encoding of strings is potentially be problematic. Would it be too much of a problem to cleanup some code style along the way? |
And I can merge this as well, feel free to ping me on the weekend about it. |
@HeroicKatora I have fixed the string issue, and changed the impls to be on |
Thank you for your contribution! |
This is a very much WIP implementation of tiff encoding. I believe that it is correct and can handle most cases, however the api is currently not very ergonomic or safe. It also lacks built-inn compression, however that kind of requires nwin/lzw#1.
Currently the api looks something like this, but I would very much like to improve it.