TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Show HN: Embed your source code in PNG files

38 pointsby cyansmokerover 3 years ago

8 comments

derefrover 3 years ago
I thought that this is what PICO-8 cartridge files (.p8.png) did; but it turns out that those use steganography within the image pixmap itself, rather than taking advantage of ancillary PNG chunks. Kind of a strange choice, honestly.<p>On a separate note, a fun fact: PNG uses what is basically a de-facto v3 of the <a href="https:&#x2F;&#x2F;en.m.wikipedia.org&#x2F;wiki&#x2F;Interchange_File_Format" rel="nofollow">https:&#x2F;&#x2F;en.m.wikipedia.org&#x2F;wiki&#x2F;Interchange_File_Format</a> . PNGs can be parsed and generated with generic IFF tools. (Which can also be used to operate on AIFF, TIFF, and—perhaps surprisingly—Erlang .beam files.)<p>IFF is, IMHO, an incredibly underutilized “metaformat” for how simple it is to work with, how observable&#x2F;inspectable the results are (for a binary file format), and yet how efficient it is (compared to text-based formats.)<p>PNG’s (backward-compatible) extensions over IFF are all pretty great ideas as well — e.g. using chunk name capitalization as metadata to mark chunks as optional (plus a few other things); linking chunks with checksums to indicate when derived chunks need to be recalculated; etc. If these extensions were promoted to features of the metaformat itself, that’d make probably the best document-oriented container metaformat around, beating e.g. “a zip file with a META-INF dir inside” by a wide margin. Sadly, AFAIK, nobody has tried to write a formal IFFv3 RFC to formalize these extensions. (Maybe something I’ll do one day myself.)
评论 #29658025 未加载
cyansmokerover 3 years ago
If you are like me, you spend a non-negligible amount of time creating architectural diagrams using a DSL (UML, python libraries or what not), exporting them to a portable image format and uploading these to some form of Wiki.<p>I would like to be able to edit everything I store in said Wiki, and this flow breaks when it comes to images. Inspired by draw.io, I created this simple util that lets me (and you) store the diagram&#x27;s code with the image. Now, as long as you have the final image, you and others can keep editing your diagram!
评论 #29659570 未加载
评论 #29671656 未加载
userbinatorover 3 years ago
I thought the first question in the FAQ was amusing:<p><i>FAQ Is this an Electron app?</i><p>It&#x27;s a few MB, which is a two orders of magnitude below Electron size, but still seems rather large for what it does; especially the CLI version.
评论 #29658376 未加载
javajoshover 3 years ago
Cool. But something I want to know is: what are the limits of the text chunk in PNG? I just browsed the specification[1] but there was no mention of it.<p>It&#x27;s also interesting to me that the spec says that the viewer should give the user a way to look at all the textual parts of a png (there are three), although I&#x27;ve never seen this offered.<p>[1] <a href="https:&#x2F;&#x2F;www.w3.org&#x2F;TR&#x2F;PNG&#x2F;#13Text-chunk-processing" rel="nofollow">https:&#x2F;&#x2F;www.w3.org&#x2F;TR&#x2F;PNG&#x2F;#13Text-chunk-processing</a>
评论 #29657449 未加载
MontagFTBover 3 years ago
Adobe Fireworks used to do something similar to this. Their base file format was a PNG of the document composite, and their proprietary data was stored in a nonstandard chunk (which was safely ignored by standard PNG readers). Thus a client could always see the latest of a file simply by sharing it with them- no Fireworks required.
评论 #29665933 未加载
评论 #29657917 未加载
Terry_Rollover 3 years ago
Is this a troll post considering the NSO hacking post seen here <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=29640474" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=29640474</a> and the google project zero post? <a href="https:&#x2F;&#x2F;googleprojectzero.blogspot.com&#x2F;2021&#x2F;12&#x2F;a-deep-dive-into-nso-zero-click.html" rel="nofollow">https:&#x2F;&#x2F;googleprojectzero.blogspot.com&#x2F;2021&#x2F;12&#x2F;a-deep-dive-i...</a><p>What is being described will get you on your way to the NSO hack as a service, because their hack was using a decompression algo to build a virtual cpu of sorts and run it, in a single pass of the decompression process.<p>How hard would it be to embed source code in such a way that you could also build a limited cpu to then run this embedded source code in memory with a single pass of graphic processing or decompression algo?
评论 #29658257 未加载
withinrafaelover 3 years ago
Is this preferable over concatenating the code onto the end of the file? The PNG structure remains intact and no app needed for insertion and extraction, right?
netr0uteover 3 years ago
What about the opposite, embedding PNG files into source code?
评论 #29657830 未加载
评论 #29657417 未加载
评论 #29657400 未加载
评论 #29657590 未加载