mirror of
https://github.com/wassname/scikit-image.git
synced 2026-06-30 11:44:53 +08:00
Use io.BytesIO instead of StringIO
Fixes NameError: global name 'io' is not defined on Python 3
This commit is contained in:
+5
-7
@@ -1,14 +1,12 @@
|
||||
__all__ = ['Image', 'imread', 'imread_collection', 'imsave', 'imshow', 'show',
|
||||
'push', 'pop']
|
||||
|
||||
from skimage.io._plugins import call as call_plugin
|
||||
from skimage.color import rgb2grey
|
||||
from io import BytesIO
|
||||
|
||||
import numpy as np
|
||||
|
||||
try:
|
||||
import cStringIO as StringIO
|
||||
except ImportError:
|
||||
import StringIO
|
||||
from skimage.io._plugins import call as call_plugin
|
||||
from skimage.color import rgb2grey
|
||||
|
||||
|
||||
# Shared image queue
|
||||
@@ -49,7 +47,7 @@ class Image(np.ndarray):
|
||||
return self._repr_image_format('jpeg')
|
||||
|
||||
def _repr_image_format(self, format_str):
|
||||
str_buffer = StringIO.StringIO()
|
||||
str_buffer = BytesIO()
|
||||
imsave(str_buffer, self, format_str=format_str)
|
||||
return_str = str_buffer.getvalue()
|
||||
str_buffer.close()
|
||||
|
||||
Reference in New Issue
Block a user