Skip to content

Instantly share code, notes, and snippets.

@gavinmh
Created July 18, 2017 00:23
Show Gist options
  • Save gavinmh/6b5f88c440f029017809bd3988582ae9 to your computer and use it in GitHub Desktop.
Save gavinmh/6b5f88c440f029017809bd3988582ae9 to your computer and use it in GitHub Desktop.
PIL to NumPy to PIL
import numpy
import PIL
# Convert Image to array
img = PIL.Image.open("foo.jpg").convert("L")
arr = numpy.array(img)
# Convert array to Image
img = PIL.Image.fromarray(arr)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment