You can use newer OpenCV python interface (if I'm not mistaken it is available since OpenCV 2.2). It natively uses numpy arrays:

import cv2
im = cv2.imread("abc.tiff")
print(type(im))

result:

<type 'numpy.ndarray'>
Answer from Andrey Kamaev on Stack Overflow
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ how-to-convert-images-to-numpy-array
How to Convert images to NumPy array? - GeeksforGeeks
July 15, 2025 - The result is a 3D array of shape (200, 400, 3) representing a color image. Example 2: In this example, we use np.array() from NumPy to convert an image into a NumPy array.
Discussions

How convert image to an array in python - Stack Overflow
I want to convert image (.jpg) to binary array. Because I have to use this array to my scrambler operating on it saved in file. Which library and and functions should I use? More on stackoverflow.com
๐ŸŒ stackoverflow.com
Converting between PIL Image and 2d pixel array?
Are you trying to translate a image into ascii art? More on reddit.com
๐ŸŒ r/learnpython
5
3
May 11, 2022
PIL image to array (numpy array to array) - Python - Stack Overflow
I have a .jpg image that I would like to convert to Python array, because I implemented treatment routines handling plain Python arrays. It seems that PIL images support conversion to numpy array... More on stackoverflow.com
๐ŸŒ stackoverflow.com
April 2, 2017
python - How to convert images into numpy array - Stack Overflow
I faced a problem when converting images into array, when reshaping the array this shows to me ValueError: cannot reshape array of size 43200 into shape (3,120,160) This my code: img_size = 224 i ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
January 16, 2021
๐ŸŒ
DataCamp
datacamp.com โ€บ doc โ€บ numpy โ€บ converting-images-to-numpy
Converting Images to NumPy
In this example, the image is converted to grayscale using `.convert('L')` before converting it to a NumPy array, then printed.
๐ŸŒ
AskPython
askpython.com โ€บ python โ€บ examples โ€บ convert-images-to-numpy-arrays
How to Convert Images to Numpy Arrays in Python - AskPython
April 21, 2026 - For most general Python work, Pillow with numpy.asarray() is the simplest choice. OpenCV wins on speed for bulk image processing. scikit-image fits naturally into scipy-based ML pipelines. Keras is the clear option when you are already working inside a TensorFlow or Keras model. The most common source of bugs is mixing up BGR and RGB. OpenCV uses BGR, everything else uses RGB. If color looks wrong after converting an OpenCV array, flip the channel order first.
๐ŸŒ
Amanxai
amanxai.com โ€บ home โ€บ all articles โ€บ convert image to array using python
Convert Image to Array using Python | Aman Kharwal
June 20, 2021 - Converting an image to an array is an important task to train a machine learning model based on the features of an image. We mainly use the NumPy library in Python to work with arrays so we can also use it to convert images to an array.
๐ŸŒ
Pluralsight
pluralsight.com โ€บ blog โ€บ tech guides & tutorials
Importing Image Data Into NumPy Arrays | Pluralsight
April 15, 2025 - The shape of the array is 800 pixels wide by 450 pixels high and 3 denotes color channels for red, green, and blue. In Python, Pillow is the most popular and standard library when it comes to working with image data. NumPy uses the asarray() class to convert PIL images into NumPy arrays.
Find elsewhere
๐ŸŒ
Benmather
benmather.info โ€บ dr. ben mather โ€” geophysicist โ€บ posts โ€บ convert images to arrays
Convert images to arrays | Dr. Ben Mather โ€” Geophysicist | The University of Melbourne
July 8, 2022 - E.g. data = np.ma.array(value_array[index], mask=(d > 70)). This would mask out the black text and white background in the image. I donโ€™t know a better way to map the RGB colour arrays to data than to query entries in a KDTree. If you do, please mention in the comments below. Now that we have converted an image into an array we can reduce the data so that only the important bits remain.
๐ŸŒ
GitHub
github.com โ€บ Jugal-Chanda โ€บ Convert-image-to-an-array-for-making-dataset
GitHub - Jugal-Chanda/Convert-image-to-an-array-for-making-dataset
It is even required for simple ... at first we need to import asarray function from numpy. The asarray() function is used to convert an given input to an array....
Author: Jugal-Chanda
๐ŸŒ
YouTube
youtube.com โ€บ shorts โ€บ w1vYW41HpKU
Converting an Image to a NumPy Array! #python #programming - YouTube
The code within the tutorial can be found via the link below on GitHub.Notebook on GitHub: https://github.com/ad17171717/YouTube-Tutorials/tree/main/YouTube%...
Published: April 15, 2025
๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ converting between pil image and 2d pixel array?
r/learnpython on Reddit: Converting between PIL Image and 2d pixel array?
May 11, 2022 -

I need to do the following:

  1. Import an image.

  2. Convert image to a 2D array of pixel values (rgb tuples, bytes, whatever it doesn't matter).

  3. Manipulate that 2D array (needs to be 2D as I'm using a library that requires a 2D array of data).

  4. Convert the newly changed 2D array back into an image.

  5. Save the image.

Anyone know how I can accomplish this? PIL Image documentation has some functions to get data but it's all 1D arrays, and I'm not sure how to get them into 2D arrays and then re-convert it back into an image again.

๐ŸŒ
PyPI
pypi.org โ€บ project โ€บ images-into-array
pip install images-into-array
images-into-array is a Python package for loading multiple images from a directory, resizing them to a common size, optionally converting them into different OpenCV color spaces, and returning them as NumPy arrays.
๐ŸŒ
YouTube
youtube.com โ€บ videos
072 Turn Images Into NumPy Arrays - YouTube
Machine Learning and Data Science
Published: June 6, 2020
Views: 20K
๐ŸŒ
w3resource
w3resource.com โ€บ python-exercises โ€บ numpy โ€บ python-numpy-exercise-108.php
Python NumPy: Convert a PIL Image into a NumPy array - w3resource
August 29, 2025 - # Importing the NumPy library and aliasing it as 'np' import numpy as np # Importing the PIL library for handling image data import PIL # Opening an image file 'w3resource-logo.png' using PIL's Image module and storing the image data in 'img_data' img_data = PIL.Image.open('w3resource-logo.png') # Converting the image data into a NumPy array and storing it in 'img_arr' img_arr = np.array(img_data) # Printing the NumPy array representation of the image print(img_arr)
๐ŸŒ
YouTube
youtube.com โ€บ it guys
How to convert images to NumPy arrays - 20 - YouTube
Hello everyone! Today is the last video of the NumPy series! In this video we will learn how to convert images in NumPy arrays!This is really useful as you w...
Published: August 3, 2020
Views: 20K
๐ŸŒ
Cloudinary
cloudinary.com โ€บ home โ€บ convert image to numpy array: methods, tips, and examples
Convert Image to NumPy Array: Methods, Tips, and Examples | Cloudinary
January 24, 2026 - It reads the image file, handles color modes, and provides access to the raw pixel data. When a Pillow image is passed to the NumPy np.array() function, it converts the image into an array, where each element represents a pixel value.
๐ŸŒ
scikit-image
scikit-image.org โ€บ skimage-tutorials โ€บ lectures โ€บ 00_images_are_arrays.html
Images are numpy arrays โ€” Image analysis in Python
Images are represented in scikit-image using standard numpy arrays. This allows maximum inter-operability with other libraries in the scientific Python ecosystem, such as matplotlib and scipy. Letโ€™s see how to build a grayscale image as a 2D array:
๐ŸŒ
Stack Overflow
stackoverflow.com โ€บ questions โ€บ 65755373 โ€บ how-to-convert-images-into-numpy-array
python - How to convert images into numpy array - Stack Overflow
January 16, 2021 - CopyValueError: cannot reshape array of size 43200 into shape (3,120,160) ... Copyimg_size = 224 i = 0 for _file in train_files: img = load_img(data_dir + "/" + _file , target_size=(224,224)) # this is a PIL imageflowers[0], target_size=(224,224)) img.thumbnail((image_width, image_height)) # Convert to Numpy Array x = img_to_array(img) x = x.reshape((3, 120, 160)) # Normalize x = (x - 255.0) / 255.0 dataset[i] = x i += 1 if i % 250 == 0: print("%d images to array" % i) print("All images to array!")
๐ŸŒ
YouTube
youtube.com โ€บ shixak academics
Loading an image in python as a numpy array - YouTube
Loading an image in python as a numpy array using 3 APIs1. PIL, pillow, Python Imaging Library2. OpenCV(cv2)3. Scikit-Image(skimage)
Published: September 6, 2019
Views: 30K