embedded images in html file with xxd ?

blavoie
Posts: 16
Joined: Sat Jan 21, 2017 6:41 pm

embedded images in html file with xxd ?

Postby blavoie » Sat Jan 28, 2017 1:07 pm

I'm working on an embedded esp32 design using one of the webserver examples that is included in the esp-idf examples. I'm able to get device into soft AP mode and display a simple webpage. Now that I have that working, I'm trying to build a page with a graphic.

I'm using the linux hex tool "xxd -i " to convert the html file into a hex dump array for the C include file. It works fine if the document is just HTML, but I'm stuck on trying to include an image.

I went as far as using xxd on both the HTML file and the image file and using "netconn_write" to write out both files. I also tried combining them into a single hex dump file.

At this point I'm not sure how to proceed, am I taking the wrong approach with this?

Any help is greatly appreciated.

dspau1
Posts: 13
Joined: Sat Jan 14, 2017 9:25 am

Re: embedded images in html file with xxd ?

Postby dspau1 » Sun Jan 29, 2017 9:40 am

If it's only a couple of images on the page you could embed them directly in the html as base64 before you convert the html to hex array:

<img alt="Embedded Image" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIA..." />

If you want to be super efficient, gzip the html page including the embedded base64 images before you convert to a hex array, and then set the Content-Encoding response header to "gzip" 8-)

blavoie
Posts: 16
Joined: Sat Jan 21, 2017 6:41 pm

Re: embedded images in html file with xxd ?

Postby blavoie » Sun Jan 29, 2017 2:34 pm

thank you so much for your help, I can't tell you how much I appreciate it.

Who is online

Users browsing this forum: No registered users and 118 guests