Embeding Images inside HTML ??!@#$

M

Mel

Is it possible to embed images inside HTML code at all ? rather than
fetching them from /images directory ?

maybe stupid to do, but....
 
J

Jan Clemens Faerber

Mel said:
Is it possible to embed images inside HTML code at all ? rather than
fetching them from /images directory ?

maybe stupid to do, but....

if it is just a simple animated smilie you can embed it with curl.
 
L

Leif K-Brooks

Mel said:
Is it possible to embed images inside HTML code at all ? rather than
fetching them from /images directory ?

You could do it with the data pseudo-protocol and base-64 encoding, but
it'd slow down page loading a lot, and there's a lack of browser
support. You could even use a hack with table backgrounds or CSS, but
that'd be slower than a Commodore 64 trying to run Doom 3.
 
M

Mitja

Leif K-Brooks said:
...
You could even use a
hack with table backgrounds or CSS, but that'd be slower
than a Commodore 64 trying to run Doom 3.

How would that be done? Just curiosity.
 
L

Leif K-Brooks

Chris said:
How long did it take you to type all that? :)

Heh, I don't have quite *that* much time on my hands. I used a
quick-and-dirty Python script:


import Image
def chunks(seq, chunk_size=2):
"""This function returns a generator which iterates over the chunks
of a sequence. The first argument is the sequence to find chunks
of, and the second is the size of chunks (defaults to 2). For
instance, chunks("foobar", 2) will iterate over "fo", "ob", "ar".
"""
for chunk_start in xrange(0, len(seq), chunk_size):
chunk_end = chunk_start + chunk_size
yield seq[chunk_start:chunk_end]
img = Image.open('dandelion.jpeg')
html = open('image.html', 'w')
html.write('''<style type="text/css">
td {
width : 1px;
height : 1px;
}
</style>
<table cellspacing="0" cellpadding="0">\n''')
for line in chunks(list(img.getdata()), img.size[0]):
html.write('<tr>')
for pixel in line:
html.write('<td bgcolor="#%02X%02X%02X"></td>' % pixel)
html.write('</tr>\n')
html.write('</table>')
 
C

Clemens

Jan said:
if it is just a simple animated smilie you can embed it with curl.

.... let me correct this now:

Brucie wrote in
Message-ID: said:
What is "curl"?

similar to flash but far more advanced.
http://www.curl.com/html/

<snip>

.... but I was talking about SVG
http://www.w3.org/Consortium/Offices/Presentations/SVG/
<q>If your browser is SVG enabled, or you have
a separate SVG viewer, you can start the tutorial</q>

and the smilie is an example on
http://svg.tutorial.aptico.de/showroom/index_shwrm.php
"Don't touch me"


SMIL, XML, CURL, SVG ... they all go hand in hand.
 
T

Toby Inkster

Clemens said:
... let me correct this now:

The correct way to do it would be to use a "data:" URL, but IE doesn't
support those.

Of course, the cute hack would be...

1. Use a "data:" URL to show a picture. Make sure the picture is
in XBM format. XBM is a rather obscure format, but for historial
reasons is supported by nearly all browsers. It is also ASCII-
based, so very parseable.

2. Use a small piece of Javascript to extract the data from the
URL, parse the image, and reconstruct it client-side on those
browsers that don't natively support "data:" URLs.

No, I don't want to write that script!
 
J

Jan Faerber

Toby Inkster loudly proclaimed:
The correct way to do it would be to use a "data:" URL, but IE doesn't
support those.

Of course, the cute hack would be...

1. Use a "data:" URL to show a picture. Make sure the picture is
in XBM format. XBM is a rather obscure format, but for historial
reasons is supported by nearly all browsers. It is also ASCII-
based, so very parseable.

2. Use a small piece of Javascript to extract the data from the
URL, parse the image, and reconstruct it client-side on those
browsers that don't natively support "data:" URLs.

No, I don't want to write that script!

Oh - don't say this! When you work in the Walt Disney Studios or when you
can enliven an Ork in LOTR... I mean isn't it a kind of movie you have in
mind when you use XML?
 
T

Toby Inkster

Jan said:
Oh - don't say this! When you work in the Walt Disney Studios or when you
can enliven an Ork in LOTR... I mean isn't it a kind of movie you have in
mind when you use XML?

Huh?

Normally I have ninjas in my mind.
 
J

Jan Faerber

Toby Inkster loudly proclaimed:
Huh?

Normally I have ninjas in my mind.

I chatted with someone who said that he know somebody who wrote some stuff
with SVG to interact with machines - sounds like a remote control.

But normally ninjas don't use such tools like fast boats without any
passengers driven by a modern nokia's number navigation with video
connection to set the course for the bomb.
 
J

Jan Faerber

Jan Faerber said:
Toby Inkster loudly proclaimed:


I chatted with someone who said that he know somebody who wrote some stuff
with SVG to interact with machines - sounds like a remote control.

But normally ninjas don't use such tools like fast boats without any
passengers driven by a modern nokia's number navigation with video
connection to set the course for the bomb.

http://tinyurl.com/646zr ... is this the right stuff for a model railway?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top