←back to thread

A new PNG spec

(www.programmax.net)
625 points bluedel | 1 comments | | HN request time: 0.203s | source
Show context
joshmarinacci ◴[] No.44378719[source]
A fun trick I do with my web based drawing tools is to save a JSON representation of your document as a comment field inside of a PNG. This way the doc you save is immediately usable as an image but can also be loaded back into the editor. Also means your downloads folder isn’t littered with unintelligible JSON files.
replies(12): >>44379250 #>>44379645 #>>44379652 #>>44379867 #>>44379992 #>>44380435 #>>44380543 #>>44380616 #>>44380678 #>>44380701 #>>44380930 #>>44384671 #
tomtom1337 ◴[] No.44379250[source]
Could you expand on this? It sounds a bit preposterous to save a text, as json, inside an image - and then expect it to be immediately usable… as an image?
replies(6): >>44379341 #>>44379343 #>>44379377 #>>44379491 #>>44379812 #>>44380371 #
1. bitpush ◴[] No.44379343[source]
Not OP, but PNG (and most image/video formats) allows metadata and most allows arbitrary fields. Good parsers know to ignore/safely skip over fields that they are not familiar with.

https://dev.exiv2.org/projects/exiv2/wiki/The_Metadata_in_PN...

This is similar to HTTP request headers, if you're familiar with that. There are a set of standard headers (User-Agent, ETag etc) but nobody is stopping you from inventing x-tomtom and sending that along with HTTP request. And on the receiving end, you can parse and make use of it. Same thing with PNG here.