gopherdata / gophernotes

The Go kernel for Jupyter notebooks and nteract.
MIT License
3.85k stars 264 forks source link

How to display an image from my local drive ? #146

Closed hlalibe closed 6 years ago

hlalibe commented 6 years ago

Saw the code to display an image from an URL: https://github.com/gopherdata/gophernotes/blob/master/examples/Display.ipynb

Works nicely. How can I reuse this code to display an image from my local drive ? I tried :

import (
    "net/http"
    "io/ioutil"
)
resp, err :=  os.Open("/media/test.png")
bytes, err := ioutil.ReadAll(resp.Body)
resp.Body.Close()
display.PNG(bytes)

But I get: type os.File has no field or method "Body": resp.Body

hlalibe commented 6 years ago

I'm trying this and it works, don't know if it's the best way though:

import (
    "io/ioutil"
)
bytes, err := ioutil.ReadFile("/media/test.png")
display.PNG(bytes)
cosmos72 commented 6 years ago

Compact and readable, I'd say it's a good way