jklmnn / imagejs

Small tool to package javascript into a valid image file.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support for jpeg?

nitishxp opened this issue · comments

just it give support for jpeg ?

commented

I didn't implement jpeg support because the magic byte at the beginning wasn't as ASCII character. But since JavaScript supports Unicode symbols in its variables it might be possible.
At least ÿØ, the magic byte 0xffd8 is a valid JavaScript identifier.
I'll try to add this when I have time.

commented

I did some research and tried to create a JavaScript file with a JPEG header but it fails to run in Firefox and Chrome. Both browsers complain about an illegal symbol (ÿØ) in the code. Since I cannot avoid the magic byte, I don't see any way to support JPEG.

Ok thank u @jklmnn appreciate that u spend time for my questions.
Thanks :)

Does this technique works on new browser ? if yes can u show me a small example ? because i tried its not working

commented

A small example would be:

<html>
  <head>...</head>
  <body>
    <script src="image.js.gif"/>
  </body>
</html>

where image.js.gif is the gif file created by imagejs gif image.js.

About the browser support. I made this tool a few years ago and some browsers fixed that behaviour completely, Chrome for example (see #5). Also many security and script blocking addons (e.g. NoScript for Firefox) block this behaviour.

Ok thank you for the help :)