def roundtrip(img, plugin, suffix):
 if ('.' not in suffix):
  suffix = ('.' + suffix)
 temp_file = NamedTemporaryFile(suffix=suffix, delete=False)
 fname = temp_file.name
 temp_file.close()
 io.imsave(fname, img, plugin=plugin)
 new = io.imread(fname, plugin=plugin)
 try:
  os.remove(fname)
 except Exception:
  pass
 return new

def roundtrip ( img , plugin , suffix ) : if ( '.' not in suffix ) : suffix = ( '.' + suffix ) temp_file = NamedTemporaryFile ( suffix = suffix , delete = False ) fname = temp_file . name temp_file . close ( ) io . imsave ( fname , img , plugin = plugin ) new = io . imread ( fname , plugin = plugin ) try : os . remove ( fname ) except Exception : pass return new
save and read an image using a specified plugin .