Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does HTML allow for embedded encoding of images by stream?

Tags:

html

image

Example:

<div id="sampleimage">

***Stream or Serialize JPEG Image from Server Here w/o Sending another Request***

</div>

So basically, send everything in a single response.

like image 636
danmine Avatar asked Mar 01 '09 23:03

danmine


People also ask

How to embed Base64 encoded images in HTML?

Images encoded with Base64 can be embedded in HTML by using the <img> tag. This can help to increase the page load time for smaller images by saving the browser from making additional HTTP requests. Base64 encoding and Data URL go hand-in-hand, as Data URLs reduce the number of HTTP requests that are needed for the browser to display an HTML ...

Do Base64 encoded images cost more space&bandwidth?

3 It will definitely cost you more space & bandwidth if you want to use base64 encoded images. However if your site has a lot of small images you can decrease the page loading time by encoding your images to base64 and placing them into html.

Is there any way to embed a large image in HTML?

But even if there are no file size constraints, this HTML facility was not really meant to be used for large images. Before you can embed the image, you will have to get the text equivalent of the image. How this is done depends on the operating system you're using. If you use Windows, open a command prompt.

What is the maximum file size for embedding an image?

For example, Microsoft Edge limits the size of the embedded data to 4 GB. But even if there are no file size constraints, this HTML facility was not really meant to be used for large images. Before you can embed the image, you will have to get the text equivalent of the image. How this is done depends on the operating system you're using.


2 Answers

In some browsers (in FF, Chrome, and apparently IE8) you can use the data URL scheme to embed an image file in HTML.

It looks something like this (taken from the RFC):

<IMG
   SRC="data:image/gif;base64,R0lGODdhMAAwAPAAAAAAAP///ywAAAAAMAAw
   AAAC8IyPqcvt3wCcDkiLc7C0qwyGHhSWpjQu5yqmCYsapyuvUUlvONmOZtfzgFz
   ByTB10QgxOR0TqBQejhRNzOfkVJ+5YiUqrXF5Y5lKh/DeuNcP5yLWGsEbtLiOSp
   a/TPg7JpJHxyendzWTBfX0cxOnKPjgBzi4diinWGdkF8kjdfnycQZXZeYGejmJl
   ZeGl9i2icVqaNVailT6F5iJ90m6mvuTS4OK05M0vDk0Q4XUtwvKOzrcd3iq9uis
   F81M1OIcR7lEewwcLp7tuNNkM3uNna3F2JQFo97Vriy/Xl4/f1cf5VWzXyym7PH
   hhx4dbgYKAAA7"
   ALT="Larry">

You can see that the data for the image is encoded in base64. I believe you can also use this format to assign images in javascript and to use them in CSS.

like image 143
Daniel LeCheminant Avatar answered Sep 17 '22 14:09

Daniel LeCheminant


Yes, it is possible: See here

like image 38
Johannes Weiss Avatar answered Sep 17 '22 14:09

Johannes Weiss