Back to articles
OpenCV vs Pillow: Image Processing Speed Benchmark

OpenCV vs Pillow: Image Processing Speed Benchmark

via Dev.to PythonTildAlice

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. 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_counte

Continue reading on Dev.to Python

Opens in a new tab

Read Full Article
7 views

Related Articles