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

Size #4

Closed
gtkpr opened this issue Dec 25, 2021 · 2 comments
Closed

Size #4

gtkpr opened this issue Dec 25, 2021 · 2 comments

Comments

@gtkpr
Copy link

gtkpr commented Dec 25, 2021

Was not sure where else to ask this, but it is unclear how big the files can be. In other words, how much source code can be embedded? What is the largest file size? What is the collective size of many files? Thanks

@Fusion
Copy link
Owner

Fusion commented Dec 25, 2021

Hi. Technically, you can embed one source code file per png file.
The maximum length of a PNG chunk is, theoretically, 2GB. You may have noticed that the chunk content is base64-encoded; base64 typically uses n * 3 / 4 space; this means that around 1.5 GB are available. Not bad (seriously!) but the story doesn't end here: the text being stored is compressed using the deflate algorithm. If your embedded text was English (with most DSLs requiring a considerably smaller dictionary) it would compress by a factor of roughly 3.

In conclusion, I have not tried it myself but you may be able to store about 4.5 GB of text. Note that the tool may end up using ungodly amounts of RAM if you attempt that! :)

Edit I felt it was important to put this in perspective so here goes: The Complete Works of William Shakespeare is about 5.34MiB. It could therefore fit more than 582 times in a picture's text chunk.
In conclusion: the png specification is awesome.

@gtkpr
Copy link
Author

gtkpr commented Dec 25, 2021

@Fusion <3 Very cool!

@Fusion Fusion closed this as completed Jan 16, 2022
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

No branches or pull requests

2 participants