0

I am working on a project where I have to display certain variables/counters on a webpage. Rather than using socket.io I want to convert my variable into an image.

By image I mean if the variable was x = 2; I need 2 to be converted into an image like this: The number 2 in the form of an image

I have already found a way to send image bit by bit to my html page using flask. If I can convert the variable like this then I could easily display it on my webpage.

If anyone could give any ideas it would be great.

Thanks!

Community
  • 1
  • 1
  • If you already can send the image from Flask to the web page, then you should just need to map the variable value to the corresponding image correct? – Alex W Apr 03 '20 at 16:01
  • Yes exactly, but for every value I need to display an image of that number, if that makes sense. – Usama Rahman Khan Apr 03 '20 at 16:14
  • You could use a [JavaScript Canvas](https://www.w3schools.com/html/html5_canvas.asp) to [convert text to an image](https://stackoverflow.com/questions/923885/capture-html-canvas-as-gif-jpg-png-pdf). – Jack Apr 03 '20 at 16:23
  • But how do I tell my JavaScript what the text is. How do I send the text from my flask app to js? – Usama Rahman Khan Apr 03 '20 at 16:29
  • You can [generate the image in Python](https://stackoverflow.com/questions/17856242/convert-string-to-image-in-python) – pidge Apr 03 '20 at 16:46
  • this might be helpful thankyou so much pidge – Usama Rahman Khan Apr 03 '20 at 16:54

0 Answers0