Live data from Hacker News

This JPEG is also a webpage

lcamtuf.coredump.cx

41–50 of 236 posts

Re: This JPEG is also a webpage

#42
Right-clicking on the image and selecting "View Image" (Firefox), or "Open image in a new tab" (Chromium), gives the webpage, not the image. I can see why that happens: the menu items just open a URL and don't force it to be an image. However, it was a bit disorienting.

Re: This JPEG is also a webpage

#43
post #6

You can use URI to embed images too, not sure how this is done though, why not just use URI?

Data URIs are useful for embedding resources in a page (e.g. a single HTML file containing all of its own CSS, JS, images, etc.)

This is different: it's a single file which can be parsed as either a HTML page or a JPEG. Hence, when a program expects a HTML page (like a browser loading a Web page), it will be parsed and displayed as a HTML page. When a program expects a JPEG file (like a browser loading the "src" of an "img" element) it will be parsed and displayed as a JPEG.

The trick is to use each format's comment syntax to hide the other format. Not sure if the HTTP headers need to be set differently for each request or not.

Re: This JPEG is also a webpage

#44
post #4

I abused this concept to compress demo code in PNG files, with great success. http://demoseen.com/blog/2011-08-31_Superpacking_JS_Demos.ht... This is, at present, the most efficient way to pack demos on the web; a few characters of uncompressed bootstrap code, then the rest is deflated.

Seems like some bits are missing on that page, e.g. I see nothing between "What is the bootstrap? Well, it's what turns our PNG into code and runs it. Here's the one I use:" and "The 4968 here is really the size of the decompressed data in bytes times 4"

Good catch -- thank you! Imported this from an older blog and must've lost that code block somehow.

Re: This JPEG is also a webpage

#45
post #27

A testament to one of the worst decisions in computing history - not to fail displaying a web page with an error message in case it is not a valid HTML document.

I kinda agree, but one has to concede that XHTML has failed for a reason.

Re: This JPEG is also a webpage

#46
post #27

A testament to one of the worst decisions in computing history - not to fail displaying a web page with an error message in case it is not a valid HTML document.

Or one of the best. Switch wen browsers to strict processong and you will hardly find working web page.

Well of course if correctness is not a requirement then it's not being paid attention to. That doesn't in any way indicate that it was a good decision not to require it in the first place.

Re: This JPEG is also a webpage

#47
post #9

Earlier quoted context omitted.

He placed HTML inside a COM (comment) segment of the JPEG, which is perfectly legal. The ending of his HTML is " http://dev.exiv2.org/projects/exiv2/wiki/The_Metadata_in_JPE...

Actually the browser isn't ignoring the first bytes of the JPEG before the tag - it's there on the page, just hidden with CSS.

For example, see how it renders in a text browser (links here):

https://imgur.com/a/WVWpU

Re: This JPEG is also a webpage

#50
post #4

I abused this concept to compress demo code in PNG files, with great success. http://demoseen.com/blog/2011-08-31_Superpacking_JS_Demos.ht... This is, at present, the most efficient way to pack demos on the web; a few characters of uncompressed bootstrap code, then the rest is deflated.

Wow what a complete waste of time. I don't understand the infatuation with demos, let alone micro demos. they literally do nothing for me or the rest of humanity. if that's your idea of entertainment, perhaps no one has introduced you to video games...
Post reply on HN