Load image from memory in Kivy

Similar to the first answer but doesn't require img_pygame:

    from kivy.core.image import Image as CoreImage
    from kivy.uix.image import Image
    import io
    import qrcode # specific to my usecase, interchangeable with Pil.Image
    # OR
    from PIL import Image as PilImage


    msg = "text"
    image = Image(source="")
    imgIO = io.BytesIO()
    qr = qrcode.make(msg) # returns PilImage object
    qr.save(imgIO, ext='png') # equivalent to Pil.Image.save()
    imgIO.seek(0)
    imgData = io.BytesIO(imgIO.read())
    image.texture = CoreImage(imgData, ext='png').texture
    image.reload()

You could save the file into a buffer with StringIO (see this: Binary buffer in Python).

Something like:

from StringIO import StringIO
buff = StringIO()
plt.savefig(buff)
buff.seek(0)
from kivy.core.image.img_pygame import ImageLoaderPygame
imgdata = ImageLoaderPygame(buff)._data

If you want to display a binary image directly into kivy you can simply work with io module (import io) and kivy image module (kivy.uix.image)

Check this code:

from kivy.uix.image import Image, CoreImage
import io

f=open("img.jpg",'rb')

binary_data= f.read() #image opened in binary mode

data = io.BytesIO(binary_data)
img=CoreImage(data, ext="png").texture

new_img= Image()
new_img.texture= img