Create wxBitmap from jpeg file

I’m trying to create a wx.Bitmap from a downloaded jpeg file (stored at ‘link’). The following code works, but I’m having to write the response out to a file and then load the file into the bitmap. I’m hoping for a way to use the result from memory without having to go through a file.

Is there a way to do this?

req_response = request.urlopen(link)
response =

im_file = open('foo.jpg', 'wb')

bitmap = wx.Bitmap()
bitmap.LoadFile('foo.jpg', wx.BITMAP_TYPE_ANY)


io.BytesIO( b"..." )
wx.Image(stream, type=BITMAP_TYPE_ANY, index=-1)
wx.Bitmap(img, depth=BITMAP_SCREEN_DEPTH)

Just tried with a file:

data = open(r"C:\Users\xyz\Desktop\2018.jpg", "rb").read()
bitmap = wx.Bitmap( wx.Image( io.BytesIO( data ) ) )

Works perfectly! Thanks