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

pnm: Scale samples according to specified maximum #2059

Merged
merged 1 commit into from
Nov 21, 2023

Conversation

sophie-h
Copy link
Contributor

Some formats allow to specify a maximum value for samples. Before, samples were not scaled respective to this white point, decoding some images incorrectly dimmed.

PAM (P7)

I think the tests were wrong before. But I'm not 100% confident since I haven't found something to test this format in practice.

Example

Comparison of image-rs and correct rendering.

Screenshot from 2023-11-17 23-32-57 Screenshot from 2023-11-17 23-33-06

P3 3 3 20
20 0 0
0 20 0
0 0 20
20 20 0
0 20 20
20 0 20
20 20 20
0 0 0
0 0 0

src/codecs/pnm/decoder.rs Outdated Show resolved Hide resolved
@fintelia
Copy link
Contributor

Does the decoder return an error if the image sets maxval=0? If not, we need to add that or we'll end up with a divide by zero

@sophie-h sophie-h force-pushed the wip/sophie-h/pnm-sample-scaling branch from 1d2af52 to a4869fd Compare November 20, 2023 13:21
@sophie-h
Copy link
Contributor Author

Does the decoder return an error if the image sets maxval=0? If not, we need to add that or we'll end up with a divide by zero

Thanks for catching this. I added checks that make the decoder error earlier.

Some formats allow to specify a maximum value for samples.
Before, samples were not scaled respective to this
white point, decoding some images incorrectly dimmed.
@sophie-h sophie-h force-pushed the wip/sophie-h/pnm-sample-scaling branch from a4869fd to 522c57e Compare November 20, 2023 13:29
@sophie-h
Copy link
Contributor Author

CI failures seem to be hiccups?

@fintelia fintelia merged commit d19d905 into image-rs:master Nov 21, 2023
35 checks passed
@fintelia
Copy link
Contributor

Yep, everything passed when I tried rerunning. Thanks!

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