DEV Community

TildAlice
TildAlice

Posted on • Originally published at tildalice.io

OpenCV vs Pillow: Image Processing Speed Benchmark

Pillow reads images 2x faster than OpenCV. OpenCV processes them 8x faster.

I ran both libraries through the same 5,000-image dataset — random photos from ImageNet validation set, resolutions ranging from 640×480 to 4K. The results were counterintuitive enough that I double-checked my timing code three times.

Pillow (PIL fork) is the de facto standard for simple Python image work. OpenCV is the heavyweight champion of computer vision. But when you're just resizing, rotating, or converting formats — tasks that don't need fancy algorithms — which one actually wins?

The answer depends on what "processing" means to you.

Close-up of wooden tiles spelling 'Do Not Copy' on a textured surface.

Photo by Ann H on Pexels

The I/O surprise

Loading a 3840×2160 JPEG (4K resolution, ~2.8MB file size) from disk:


python
import time
import cv2
from PIL import Image

# OpenCV
start = time.perf_counter()
img_cv = cv2.imread('sample_4k.jpg')
opencv_load_time = time.perf_counter() - start
print(f"OpenCV: {opencv_load_time*1000:.2f}ms")  # 18.43ms

# Pillow
start = time.perf_counter()
img_pil = Image.open('sample_4k.jpg')
img_pil.load()  # Force actual decoding

---

*Continue reading the full article on [TildAlice](https://tildalice.io/opencv-vs-pillow-image-processing-speed-benchmark/)*
Enter fullscreen mode Exit fullscreen mode

Top comments (0)