Skip to content

Conversation

@zbjornson
Copy link
Collaborator

It seems browsers also always set the PPI to 72
-- #766 (comment)

Edge, Firefox and Chrome don't specify a pHYs chunk, so I left default behavior unchanged to stay consistent with them. (The internets say that the resolution doesn't mean much for on-screen display anyway.)

Fixes #766
Fixes #716

Thanks for contributing!

  • Have you updated CHANGELOG.md?

Copy link
Collaborator

@LinusU LinusU left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neat 👍

if (buf[i] === 0x70 &&
buf[i + 1] === 0x48 &&
buf[i + 2] === 0x59 &&
buf[i + 3] === 0x73) { // pHYs
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😄

@zbjornson zbjornson merged commit 013223f into Automattic:master Jun 15, 2018
@zbjornson zbjornson deleted the resolution branch June 15, 2018 22:24
@KFoxder
Copy link

KFoxder commented Feb 26, 2019

@zbjornson I do not see this working for me? Don't you need to update the parsePNGArgs method in this PR?

@zbjornson
Copy link
Collaborator Author

Hrm it looks like I lost the changes to canvas.cc that were supposed to be in this PR. The test passes because pHYs is omitted if resolution isn't specified. Will fix tonight. Thanks for pointing that out.

@KFoxder
Copy link

KFoxder commented Feb 26, 2019

@zbjornson Awesome thanks! Much appreciated.

@mikehalmamoj
Copy link

Hrm it looks like I lost the changes to canvas.cc that were supposed to be in this PR. The test passes because pHYs is omitted if resolution isn't specified. Will fix tonight. Thanks for pointing that out.

Did this make it onto another PR? The resolution option for png appears to do nothing...

@zbjornson
Copy link
Collaborator Author

@mikehalmamoj yes, #1376.

image

As an ancillary chunk, readers are allowed to ignore pHYs. That might be why you don't see it doing anything. Above shows that the chunk is encoded in the file correctly though.

@mikehalmamoj
Copy link

Thanks for the quick reply @zbjornson. That's ever so strange because I don't see the resolution in the image info when generating from this lib but if I add a resolution with the pngcrush CLI then I see the that resolution. 🤷‍♂️ I'll have to do some more digging.

Thanks again!

@mikehalmamoj
Copy link

You're absolutely correct and it works fine - it seems the issue is the haphazard support for the pHYs chunk. Thanks again @zbjornson and keep up the good work! 😄

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.

PNG files written with wrong resolution in header Output high resolution PNG

4 participants