You're not saying how exactly putdata() is not behaving. I'm assuming you're doing

>>> pic.putdata(a)
Traceback (most recent call last):
  File "...blablabla.../PIL/Image.py", line 1185, in putdata
    self.im.putdata(data, scale, offset)
SystemError: new style getargs format but argument is not a tuple

This is because putdata expects a sequence of tuples and you're giving it a numpy array. This

>>> data = list(tuple(pixel) for pixel in pix)
>>> pic.putdata(data)

will work but it is very slow.

As of PIL 1.1.6, the "proper" way to convert between images and numpy arrays is simply

>>> pix = numpy.array(pic)

although the resulting array is in a different format than yours (3-d array or rows/columns/rgb in this case).

Then, after you make your changes to the array, you should be able to do either pic.putdata(pix) or create a new image with Image.fromarray(pix).

Answer from dF. on Stack Overflow
🌐
Educative
educative.io › answers › convert-a-pil-image-to-numpy-array
Convert a PIL image to NumPy array
To get started, we need to install PIL and NumPy in our system. For that, we can use the following command: ... Note: Pillow is the newer version of PIL. Once the libraries are installed successfully, we can move to the next steps. We’ll use the following image and convert it into a NumPy array.
Discussions

python - How to convert a NumPy array to PIL image applying matplotlib colormap - Stack Overflow
I want to take a NumPy 2D array which represents a grayscale image, and convert it to an RGB PIL image while applying some of the matplotlib colormaps. I can get a reasonable PNG output by using the More on stackoverflow.com
🌐 stackoverflow.com
Pillow to NumPy without copying data
I hoped that the some mechanism could be used to share the memory between PIL and numpy. For my purposes, a solution that would work for RGBA 8-bit images would be good enough, but a generic solution is welcome, I've stumbled upon this a couple of time already. More on github.com
🌐 github.com
13
September 13, 2019
Python PIL image list to numpy array help
Got it to work, so for future people(Hello!): def getImages(path) : paths = [] images = [] valid_images = [".jpg",".gif",".png",".tga"] for f in os.listdir(path): ext = os.path.splitext(f)[1] if ext.lower() not in valid_images: continue paths.append(os.path.join(path,f)) paths.sort() #make sure every image is sorted correctly for p in paths : images.append(np.asarray(Image.open(os.path.join(p)))) return np.asanyarray(images) More on reddit.com
🌐 r/CodingHelp
4
3
October 26, 2021
numpy to pil to numpy, image become distorted
Image.fromarray(array, 'RGB') expects that the array contains 3x8-bit pixels. This means that if the dtype of your array is no equal to uint8 you will need to convert it first. plt.imshow accepts arrays that contain either integers between 0 and 255 or floats between 0 an 1. In the latter case you would need to multiply the array by 255 first before converting it to uint8, i.e. if issubclass(sats[i].dtype.type, np.floating): # sats[i] contains floats between 0.0 and 1.0 arr = (255*sats[i]).astype('uint8') else: # sats[i] contains integers between 0 and 255 arr = sats[i].astype('uint8') extra = np.array(Image.fromarray(arr, 'RGB')) More on reddit.com
🌐 r/learnpython
3
3
October 3, 2020
🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-convert-images-to-numpy-array
How to Convert images to NumPy array? - GeeksforGeeks
July 15, 2025 - Explanation: It converts a PIL image to a NumPy array using img_to_array() for processing, then back to a PIL image using array_to_img(), confirming smooth transformation with array type float32 and shape (200, 400, 3).
🌐
Saturn Cloud
saturncloud.io › blog › how-to-convert-rgb-pil-image-to-numpy-array-with-3-channels-a-comprehensive-guide
How to Convert RGB PIL Image to Numpy Array with 3 Channels: A Guide | Saturn Cloud Blog
February 8, 2024 - Resource Intensity: Loading large images into NumPy arrays may consume a significant amount of memory. This can be a limitation when working with high-resolution images or in memory-constrained environments. And there you have it! You’ve successfully converted an RGB PIL image to a NumPy array with 3 channels.
🌐
w3resource
w3resource.com › python-exercises › numpy › python-numpy-exercise-108.php
Python NumPy: Convert a PIL Image into a NumPy array - w3resource
Create a function that transforms a PIL image into grayscale and returns the corresponding NumPy array. Test the conversion with images of different modes (RGB, L, RGBA) and compare the array dimensions.
🌐
Pluralsight
pluralsight.com › tech insights & how-to guides › tech guides & tutorials
Importing Image Data Into NumPy Arrays | Pluralsight
April 15, 2025 - For example, the code below loads the photograph in JPEG format and saves it in PNG format. import numpy as np from PIL import Image im = np.array(Image.open('kolala.jpeg').convert('L')) #you can pass multiple arguments in single line ...
Find elsewhere
🌐
Delft Stack
delftstack.com › home › howto › numpy › pil image to numpy array
How to Convert PIL Image to NumPy Array | Delft Stack
March 11, 2025 - Here’s how you can do it: from PIL import Image import numpy as np # Open an image file image = Image.open('example_image.jpg') # Convert the image to a NumPy array image_array = np.array(image) print(image_array.shape)
🌐
Roboflow
roboflow.com › use opencv › convert pil image to numpy array
Convert PIL Image to NumPy array (OpenCV)
HOW TO GUIDE · You can convert a PIL Image object into a NumPy array using the np.asarray() function: import numpy as np from PIL import Image pil_image = Image.open("image.jpeg") image = np.asarray(pil_image) OpenCV can be used with the open source supervision Python package.
🌐
Uploadcare
uploadcare.com › processing & transformations category › fast pillow image import to numpy and opencv arrays
Fast Pillow image import to NumPy and OpenCV arrays | Uploadcare
September 7, 2021 - Now you understand why we need the tobytes() method here: it transforms the internal representation of a Pillow image into a continuous flow of bytes without omissions, and that’s exactly what NumPy can use.
🌐
DataCamp
datacamp.com › doc › numpy › converting-images-to-numpy
Converting Images to NumPy
In this syntax, `Image.open()` loads the image, and `np.array()` converts it to a NumPy array. The resulting `image_array.shape` will return a tuple representing (height, width, channels) for color images, clarifying the dimensions. from PIL import Image import numpy as np image = ...
🌐
Python Pool
pythonpool.com › home › blog › how to convert pil images to numpy array
How To Convert PIL Images to Numpy Array - Python Pool
September 10, 2022 - PIP Command for PIL/Pillow (MacOs/Linux & Windows) $ pip install Pillow · Numpy is not part of the Python Standard Library. Install using the following PIP command. PIP Command for Numpy (MacOs/Linux & Windows) $ pip install numpy · The save() function allows us to store images into multiple supported image formats.
🌐
Matias Codesal
matiascodesal.com › posts › how-convert-pillow-pil-image-numpy-array-fast
How to Convert a Pillow (PIL) Image to a Numpy Array FAST!
December 22, 2020 - Here’s an example: ... import numpy as np from PIL import Image img = Image.open(filepath) # datatype is optional, but can be useful for type conversion data = np.asarray(img, dtype=np.uint8)
🌐
Medium
medium.com › @whyamit101 › step-by-step-guide-to-convert-numpy-array-to-pil-image-f7f8492cd785
Step-by-Step Guide to Convert NumPy Array to PIL Image | by why amit | Medium
February 9, 2025 - Grayscale images are simpler to handle, with just one channel. You created a grayscale NumPy array and converted it to a PIL image using the 'L' mode.
🌐
Note.nkmk.me
note.nkmk.me › home › python › numpy
Image processing with Python, NumPy | note.nkmk.me
October 20, 2020 - Passing the image data read by PIL.Image.open() to np.array() returns 3D ndarray whose shape is (row (height), column (width), color (channel)). from PIL import Image import numpy as np im = np.array(Image.open('data/src/lena.jpg')) print(type(im)) ...
🌐
Linux Hint
linuxhint.com › pil-image-to-numpy-array
PIL Image to NumPy Array
November 9, 2022 - Linux Hint LLC, [email protected] 1210 Kelly Park Circle, Morgan Hill, CA 95037 Privacy Policy and Terms of Use
🌐
Pythoninformer
pythoninformer.com › python-libraries › numpy › numpy-and-images
PythonInformer - Image processing with pillow and NumPy
October 2, 2022 - By Martin McBride, 2022-10-02 Tags: image processing rgb transparency pil pillow Categories: numpy pillow · In this section, we will learn how to use NumPy to store and manipulate image data.
🌐
GitHub
github.com › python-pillow › Pillow › issues › 4064
Pillow to NumPy without copying data · Issue #4064 · python-pillow/Pillow
September 13, 2019 - meaning both PIL and numpy allocate memory (~35 and ~50 mb respectively). I've also tried using np.array (somehow takes 80 mb instead of 50 mb) instead of np.asarray, specifying the dtype for the numpy arrays (uint8, int32 (one long per pixel)), to no avail.
Author   HonzaCustomInk
🌐
Navan
web.navan.dev › posts › 2020-01-14-Converting-between-PIL-NumPy.html
Converting between image and NumPy array - Navan
import numpy import PIL # Convert PIL Image to NumPy array img = PIL.Image.open("foo.jpg") arr = numpy.array(img) # Convert array to Image img = PIL.Image.fromarray(arr)