Skip to content

Allow a value of 0 in pHYs chunks - #5

Open
Oondanomala wants to merge 1 commit into
nayuki:masterfrom
Oondanomala:phys
Open

Allow a value of 0 in pHYs chunks#5
Oondanomala wants to merge 1 commit into
nayuki:masterfrom
Oondanomala:phys

Conversation

@Oondanomala

Copy link
Copy Markdown
Contributor

As far as I can tell that is allowed in the spec

As far as I can tell that is allowed in the specification
@nayuki

nayuki commented Mar 30, 2026

Copy link
Copy Markdown
Owner

This is a bad idea because it can lead to division by zero.

For example, if we say that an image has "0 pixels per metre" and the image is 99 pixels wide, then its physical width is (99 pixel) / (0 pixel / metre) = (99 / 0) metre. I can't think of any acceptable use of the value zero here.

@Oondanomala

Copy link
Copy Markdown
Contributor Author

Good point, though I could see it being used to indicate only one size is known (but then what if both sizes are 0? what if the unit is unknown?).
The spec doesn't seem to forbid that so I think they should be supported (or it should be updated to disallow it, though I don't see that happening).
I remember finding files in the wild that had a size of 0, which is why I made this PR in the first place (I don't remember what the files were though, I'll try to find them again).

Or maybe the spec should be updated to explicitly define 0 as unknown?

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