Shop OBEX P1 Docs P2 Docs Learn Events
Propeller + SD + ENC28j60 = headache with HTML and images — Parallax Forums

Propeller + SD + ENC28j60 = headache with HTML and images

sebastian1989sebastian1989 Posts: 14
edited 2012-11-09 09:52 in Propeller 1
Hi, my name is Sebastian, I am from chile, please be patient, my english is bad.
I am creating a web server with a propeller, the propeller read a HTML file from SD and sends the info with the library api_telnet_serial, the problem is that, when the HTML code search for images this obviously dont find any because all image are in the SD, the solution I found is send the image inside the HTML page in base64, but when I do this the propeller needs to transform the image to base 64 and this is very slow also whith the tranform to base64 the propeller need to send 33% more info.


This is a example in HTML to put a image in base64:
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA
AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
9TXL0Y4OHwAAAABJRU5ErkJggg==" alt="Red dot">


With the program I've done so far a jpg file 1024x768 1MB takes one minute to appear on the website but when I convert the image in the PC and the propeller only need transfer it this takes 15 seconds.


Does anyone know any other way to transfer the image (not base64)?
or how to make the transformation faster?


Again I apologize for my bad English.

Comments

  • CircuitsoftCircuitsoft Posts: 1,166
    edited 2012-11-06 17:57
    With <img src="mypic.jpg">, the browser should then make a request like "GET /mypic.jpg HTTP/1.1" and you should then read the image off the SD card and send it.
  • sebastian1989sebastian1989 Posts: 14
    edited 2012-11-06 19:32
    I read all the data sent by browser, but I don't find nothing like this "GET /mypic.jpg HTTP/1.1", this is all info received:
    GET /img2.html HTTP/1.1 Host: 192.168.0.150 Connection: keep-alive Cache-Control: max-age=0 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Encoding: gzip,deflate,sdch Accept-Language: es-ES,es;q=0.8 Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3

    When the browser sends the request?
    Do I need to put some header or script to send the request?

    I am reading a HTTP manual, I'm on page 50 of 450.
  • sebastian1989sebastian1989 Posts: 14
    edited 2012-11-09 09:52
    I was finally able to find the request GET, but now when I answer and sent the image, the browser does not display the picture, I guess I have a problem with the header,this is a piece of my program.
    if str.comp(@request, string("GET /2.jpg")) <> -1                
        sock[idx].str(string("HTTP/1.1 200 OK",13,10))   
        sock[idx].str(string("Content-Type: image/jpeg",13,10))
        sock[idx].str(string("Cache-Control: public", 13, 10))
        sock[idx].str(string("Content-Length: "))
        sock[idx].dec(fat.filesize)
        sock[idx].str(string(13,10))
        sock[idx].str(string(13,10))
                                                      
        fat.openFile(string("2.jpg"), "R")
        
        siz:=fat.filesize
        repeat  siz/2048
          fat.readdata(@buff2,2048)
          buff2[2048]:=0
          sock[idx].str(@buff2)
        
        fat.readdata(@buff2,siz//2048)
        buff2[siz//2048]:=0
        sock[idx].str(@buff2)  
    
    
        fat.closefile
    
    
    

    Does anyone see the problem?
Sign In or Register to comment.