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

PNG with long iTXt chunk not detected as PNG image #320

Closed
lenartbezek opened this issue Jan 27, 2020 · 3 comments · Fixed by #321
Closed

PNG with long iTXt chunk not detected as PNG image #320

lenartbezek opened this issue Jan 27, 2020 · 3 comments · Fixed by #321
Assignees

Comments

@lenartbezek
Copy link
Contributor

Some PNG images have long iTXt chunks so the parser never reaches IDAT chunk.

When printing chunks after the header, I get something like this:

{ length: 13, type: 'IHDR' }
{ length: 9, type: 'pHYs' }
{ length: 25204, type: 'iTXt' }

A solution perhaps would be to add a final return after this line in case the PNG header matches, but no IDAT chunk is found in first 4100 bytes. Or perhaps an extra switch case for ITXt chunk?

Example image with ITXt chunk: https://puu.sh/F4fqT.png

lenartbezek added a commit to lenartbezek/file-type that referenced this issue Jan 27, 2020
@Borewit Borewit self-assigned this Jan 27, 2020
@Borewit
Copy link
Collaborator

Borewit commented Jan 27, 2020

A solution perhaps would be to add a final return after this line in case the PNG header matches

Maybe a reasonable fallback indeed.

, but no IDAT chunk is found in first 4100 bytes. Or perhaps an extra switch case for ITXt chunk?

The 4100 sample limit is no longer in file-type (see #248, #319), except in stream().

Which function are you using?

Can you use fromFile(filePath) instead?

@Borewit
Copy link
Collaborator

Borewit commented Jan 27, 2020

I merged your (@lenartbezek) changes to #321, on top of PR #319 to get rid of the 4k side effects.

@lenartbezek
Copy link
Contributor Author

The 4100 sample limit is no longer in file-type (see #248, #319), except in stream().
Which function are you using?

I am using stream() when uploading a file and piping it directly into destination. We're not using fromFile or fromBuffer to avoid saving the entire file locally before uploading it to storage.

Borewit pushed a commit that referenced this issue Feb 1, 2020
Borewit added a commit that referenced this issue Feb 1, 2020
Co-authored-by: Lenart Bezek <lench4991@gmail.com>
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 a pull request may close this issue.

2 participants