473,880 Members | 1,968 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

embedding images in HTML with the data URL src

I have been doing some research about embedding images in HTML using
the data URL src method of the format:

<img src="/-/data:image/gif;base64,<DAT A>">

My question is, how does one generate this <DATA> string? I have found
some on the web that I can load into my browser but if I save this
image and then view in Notepad it looks much different than the string
that I used in <DATA> and is full of non-alphanumeric symbols. Also, I
have saved this image as a BLOB into my database and this format is in
turn different from the two other. What gives?

Thanks.

Edward

Jan 28 '06 #1
6 22813
Edward wrote:
I have been doing some research about embedding images in HTML using
the data URL src method of the format:
Have you studied the specification of data: URLs and the browser support
to them?
<img src="/-/data:image/gif;base64,<DAT A>">
Apparently not. And your markup isn't even valid.

Besides, even if you got it right, and even if browsers generally
supported it (say, in 2009), would it still be _useful_ to use it?
My question is, how does one generate this <DATA> string?


It's too early to ask that, since you haven't addressed the more
fundamental issues. Besides, it's not an HTML issue.
Jan 28 '06 #2
Edward wrote:
I have been doing some research about embedding images in HTML using
the data URL src method of the format:

<img src="/-/data:image/gif;base64,<DAT A>">

My question is, how does one generate this <DATA> string?


http://software.hixie.ch/utilities/cgi/data/data

--
Lachlan Hunt
http://lachy.id.au/
http://GetFirefox.com/ Rediscover the Web
http://GetThunderbird.com/ Reclaim your Inbox
Jan 28 '06 #3

Jukka K. Korpela wrote:
Edward wrote:
I have been doing some research about embedding images in HTML using
the data URL src method of the format:
Have you studied the specification of data: URLs and the browser support
to them?


I am trying to learn all I can about the data: URL. Clearly I am not
yet an expert! But I hope to learn from others in this forum and in my
other research. I am trying to progress.
<img src="/-/data:image/gif;base64,<DAT A>">


Apparently not. And your markup isn't even valid.


How so? I have been able to open images in browsers using this markup.
I found some good examples at:
http://delegate.org/delegate/sample/data-url.html.
Besides, even if you got it right, and even if browsers generally
supported it (say, in 2009), would it still be _useful_ to use it?


I hope so. I am not going to use it in the browser, per se, however.
I plan to use it to pass a parameter to Apache FOP to load an
external-graphic. I need to use a data: URL because the image
generation servlet is required to use HTTPS and FOP does not seem to
support HTTPS in an external-graphic.
My question is, how does one generate this <DATA> string?


It's too early to ask that, since you haven't addressed the more
fundamental issues. Besides, it's not an HTML issue.


I have found a web site to encode data to Base64
(http://makcoder.sourceforge.net/demo/base64.php) and a class that
someone wrote
(http://www.source-code.biz/snippets/...oder.java.txt). Using
both of these methods, I took the sample <DATA> from above (which
created the image in a browser) and then saved this image. I then used
the two methods here to try to recreate the <DATA>. The recreated
<DATA> was close but not the same as the original. I think that I must
be missing something obvious on how to create the Base64 data.

Jan 28 '06 #4
Edward <ed************ **@yahoo.com> wrote:
How so? I have been able to open images in browsers using this markup.
I found some good examples at:
http://delegate.org/delegate/sample/data-url.html.


Forget this page immediately.

The second example of this page (with the "/-/" prepended to the data
url) will result in the following:
The relative URL "/-/data:image/gif;base64,<dat a>" will be resolved
to "http://delegate.org/-/data:image/gif;base64,<dat a>" and then will be
send back to the server. The server now translates the "<data>" into a
GIF image and sends this image back to the browser which it can display.
In the first example (the real "data:" URL scheme) will result in the
following:
The URL "data:image/gif;base64,<dat a>" will be directly translated into
a GIF image by the browser and so can be directly displayed.

The differences is:
The second example needs more than the double amout of data that is send
to and from the server. And it is working only with the help
of the server, and only if the server is able to translate such
URLs. That means there must be a certain script installed on your server
in order to use this special URLs. And because of the doubled data
transmission you'll better use the ordinary way to embed images

It doesn't make any sense to prepend "/-/" to "data:" URLs.

--
Alexander
Jan 28 '06 #5
Edward <ed************ **@yahoo.com> wrote:
I have been doing some research about embedding images in HTML using
the data URL src method of the format:

<img src="/-/data:image/gif;base64,<DAT A>">

^^^^
Remove this nonsense.

"data" URLs must begin with "data:" (like "http" URLs begin with
"http:"), because otherwise the whole thing is just an ordinary relative
URL which will be resolved using the base URL of the document itself.
That means instead of letting the browser deal with the "data" directly,
this will cause the browser to send the data back to the server. If the
server is not prepared for such a stupidity, you get only an error
message. If the server is able to translate the "data" of the "false"
data-URL into the real file format, it will send back the translated
data to the browser.

But of course. this is just a very stupid thing: you've more than
doubled the amount of data that is transmitted to and from the server.
And this won't work offline anymore, without a server that is
translating the data.

--
Alexander
Jan 28 '06 #6
"Edward" <ed************ **@yahoo.com> wrote:
I am trying to learn all I can about the data: URL.
But you apparently did not even read the description of their format.
> <img src="/-/data:image/gif;base64,<DAT A>">


Apparently not. And your markup isn't even valid.


How so? I have been able to open images in browsers using this markup.


Apparently you don't even know what "valid markup" means.
I need to use a data: URL because the image
generation servlet is required to use HTTPS and FOP does not seem to
support HTTPS in an external-graphic.


Whatever that's supposed to mean, it's not about HTML authoring for the WWW,
hence off-topic for this group.

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html

Jan 28 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
8280
by: Dean J. Garrett | last post by:
Hi, I need to create HTML e-mail from an ASP program that includes embedded images that go along with the e-mail, e.g. logos, product image, etc. Is there a technique in HTML that people use to embed images? I know that when I insert an image into an e-mail in Outlook, and I look at the HTML behind it, there is a funny tak CID: IMG hspace=0 src="cid:027301c29d8e$da6ba600$0afea8c0@MYMAIN" align=baseline border=0>
1
4487
by: Chris Nafziger | last post by:
In my code to send email from VBScript, I use standard CDOSYS code similar to the following: With oMsg Set .Configuration = oCon .To = """Admin"" <admin@mycompany.com>" .From = """Joe Admin"" <jadmin@mycompany.com>" .Subject = "Hey You!" .TextBody = "Service(s) have failed!" .Send
2
3188
by: dr_tyson | last post by:
I am trying to embed images into a wxPython app (created using Boa Constructor), but have not been able to do so. I know how to embed plots, but images seem to be a problem. I've tried using code analogous to the example given at the Matplotlib website to no avail. If anybody has been successful at this could you please post some sample code? That would be greatly appreciated. Thanks! Randy
3
5698
by: Tim T | last post by:
Hi, I hope there is someone reading this that has the answer, Please Help! I have the need to send a html email via asp.net. its easy enough to send an html email and add attachments. My question is, how to you set the Content-Location of each attachment in the mail headers so that the images are embedded in the html email rather than attached? This is my code:
7
2439
by: David Thielen | last post by:
Hi; Is there a way to embed images in the response rather than writing them to disk and having an <img ...> tag? And if so, how is it done and what browsers support it? -- thanks - dave
1
5203
by: MissMarie | last post by:
I've been playing around with DIV tables in myspace to better learn how to rewrite my own code for my business site without having to pay someone to design it. I've tried embedding a slideshow into a div table and after I save it I noticed that the slideshow does not show up and the embed code I added is altered. Can anyone help me figure this out? The embed code that I'm talking about is three quarters down the code page under {PHOTOS},...
0
1396
by: macap.usenet | last post by:
Hello, i am embedding System.Web.UI.WebResources in my C# Class via: I use this resource with: Page.Header.Controls.Add(new LiteralControl("<link href='"ExtJS.yui- ext.css"' rel='stylesheet' type='text/css' />"));
5
13400
matheussousuke
by: matheussousuke | last post by:
Hello, I'm using tiny MCE plugin on my oscommerce and it is inserting my website URL when I use insert image function in the emails. The goal is: Make it send the email with the URL http://mghospedagem.com/images/controlpanel.jpg instead of http://mghospedagem.comhttp://mghospedagem.com/images/controlpanel.jpg As u see, there's the website URL before the image URL.
0
9774
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10715
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10396
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9550
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7951
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5778
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5973
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4192
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3220
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.