Display received image via socket in img tag

Asked

Viewed 69 times

0

I am receiving images from a server and need to display the image on the html page. The images are received via socket, so I have only the content of the image. The img tag displays an image when there is src, in which case would it be necessary to save the image on the client side and then display it? Thank you for your attention.

  • 1

    In what format the image is received, Base64?

  • I’m not sure what format. I use a library to extract the image from a mjpeg video on the server and send it to the client.

  • If you are Base64, this may help you: http://answall.com/a/169877/32827

  • 1

    @Lucascosta thanks for your help. To work I needed to do just this: var b64Response = btoa(image); Document.querySelector("#myimage"). src ='data:image/jpeg;Base64,'+b64Response; http://stackoverflow.com/questions/20784145/display-image-from-http-response-with-image-content-type

  • Cool @Brunoclementino, answer your question :)

1 answer

0


Browser other questions tagged

You are not signed in. Login or sign up in order to post.