I already have an in-memory file of an image. I would like to use skimage's io.imread (or equivalent) to read in the image. However, skimage.io.imread() take a file not a buffer
example buffer:
<Buffer ff d8 ff e0 00 10 4a 46 49 46 00 01 01 00 00 01 00 01 00 00 ff db 00 43 00 03 02 02 02 02 02 03 02 02 02 03 03 03 03 04 06 04 04 04 04 04 08 06 06 05 ... >
skimage.io.imread() just results in a numpy array.
Try converting the buffer into StringIO and then read it using skimage.io.imread()
import cStringIO
img_stringIO = cStringIO.StringIO(buf)
img = skimage.io.imread(img_stringIO)
You can also read it as :
from PIL import Image
img = Image.open(img_stringIO)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With