Skip to content

pnm: Scale samples according to specified maximum #2059

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

Merged
merged 1 commit into from
Nov 21, 2023

Conversation

Image for: Conversation
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.

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
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 force-pushed the wip/sophie-h/pnm-sample-scaling branch from 1d2af52 to a4869fd Compare November 20, 2023 13:21
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 force-pushed the wip/sophie-h/pnm-sample-scaling branch from a4869fd to 522c57e Compare November 20, 2023 13:29
Copy link
Contributor Author

CI failures seem to be hiccups?

fintelia merged commit d19d905 into image-rs:master Nov 21, 2023
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
2 participants