Closed Thread Icon

Topic awaiting preservation: Can you use JavaScript to read an image's comment blocks? (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=8451" title="Pages that link to Topic awaiting preservation: Can you use JavaScript to read an image&amp;#039;s comment blocks? (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: Can you use JavaScript to read an image&#039;s comment blocks? <span class="small">(Page 1 of 1)</span>\

 
Emperor
Maniac (V) Mad Scientist with Finglongers

From: Cell 53, East Wing
Insane since: Jul 2001

posted posted 01-07-2003 03:18

JPEG and GIF89a (and PNG?) allow you to embed comment blocks - is there a JavaScript way to access these comment blocks? I have had a good look around and could only find possible problem in early NS browsers that could run JavaScript inserted into these comment blocks.

Thought arose from discussion here on Creative Commons and embedding metadata into images:
http://development.gurusnetwork.com/discussion/thread/1800/

I've found various ways of using server-side scripting to read and write them but I was curious to know if it was possible to create a bookmarklet to peek into the comments. A tad esoteric I know but..........

___________________
Emps

FAQs: Emperor

reitsma
Maniac (V) Mad Scientist

From: the bigger bedroom
Insane since: Oct 2000

posted posted 01-07-2003 03:57

wheee!

code:
<html>
<head>
<script>
function dumpStuff() {
var obj = document.images[0]; // replace window with whatever object you want the properties of.
var msg = "";
for (prop in obj)
{
msg += prop + " = " + obj[prop] + "<br> ";
}
document.write(msg);
}
</script>
</head>
<body onload="dumpStuff()">
<img src='leftnav.gif' alt='hi' name='bob'>
</body>
</html>



not quite sure what you're after, but this little baby dumps the item's properties. courtesy of this tidy little thread.

tell me how you go, emps.



edit: oh yeah, make sure the image tag refers to an image and stuff...


[This message has been edited by reitsma (edited 01-07-2003).]

Emperor
Maniac (V) Mad Scientist with Finglongers

From: Cell 53, East Wing
Insane since: Jul 2001

posted posted 01-07-2003 04:28

reitsma: Thats what I love about this place - not only has the problem probably been answered before (in some form) but someone has their finger on the pulse and can pull the veritable magic rabbit out of the hat.

I'll be trying this out tomorrow - thanks

[edit: DmS also pointed me to this thread:
www.ozoneasylum.com/Forum2/HTML/001762.html ]

___________________
Emps

FAQs: Emperor

reitsma
Maniac (V) Mad Scientist

From: the bigger bedroom
Insane since: Oct 2000

posted posted 01-07-2003 04:49

heh - i have a fairly stupid form of laziness.

instead of customising that little script, making it all neat and tidy, and saving it to my hard disk, i've memorised the perfect search phrase to uniquely identify it, then try to find the best part of the thread, and recustomise it each time.

keep us updated on your progress.

Emperor
Maniac (V) Mad Scientist with Finglongers

From: Cell 53, East Wing
Insane since: Jul 2001

posted posted 01-07-2003 19:24

reitsma: I like that form of laziness (although it tends to involve more hard work)

Anyway I have inserted some RDF metadata into the Doc's Ozones button (sorry Doc) but the above code seems to pull out just about every other property other than the comments:
http://development.gurusnetwork.com/work/emperor/rdfpic/

Its possible that the comments just aren't accessible like this but it is worth having a play - I'll look and see if the idea from DmS (mentioned in my edit above) might work..........

[edit: started a new thread on this over at the GN as it was getting a little off topic:
http://development.gurusnetwork.com/discussion/thread/1808/ ]

___________________
Emps

FAQs: Emperor

Emperor
Maniac (V) Mad Scientist with Finglongers

From: Cell 53, East Wing
Insane since: Jul 2001

posted posted 01-08-2003 00:46

OK I have thrown together a quick bit of PHP which grabs a file (as its text parts) and then grabs out the relevant data.

code:
<?php

header("Content-Type: text/xml");

$grab_bits = file('ozones.jpg');

if (!empty ($grab_bits)) {

$implode_bits = implode('', $grab_bits);

eregi("<rdf:RDF(.*)</rdf:RDF>", $implode_bits, $page_trim);

$fcontents = $page_trim[0];

echo $fcontents;

}

?>



as seen here:
http://development.gurusnetwork.com/work/emperor/rdfpic/load_rdf_image.php

And (thanks to InI's prompting) I have also had a nose through the JPEG when it is opened in Notepad (you get pretty much the same again). Now is there a way to use JavaScript to read the data byte by byte? I doubt it but it is worth throwing the diea out just in case one of resident geniuses (genii) have something special up their sleeve

___________________
Emps

FAQs: Emperor

« BackwardsOnwards »

Show Forum Drop Down Menu