Skip to content

Instantly share code, notes, and snippets.

@t2psyto
Created April 6, 2015 08:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save t2psyto/5531f6f54495d1b3515e to your computer and use it in GitHub Desktop.
Save t2psyto/5531f6f54495d1b3515e to your computer and use it in GitHub Desktop.
def wand2pil(image):
width, height = image.size
depth = image.depth
if image.colorspace == 'gray':
channs = 1
fmt = 'gray'
else:
channs = 3
fmt = 'RGB'
image.depth = 16
imgArray = np.ndarray((height, width, channs), dtype='uint16', buffer=image.make_blob(fmt))
c = numpy.uint8(imgArray)
pilImg = Image.fromarray(c)
return pilImg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment