Use Pillow for opening, converting, resizing, drawing on and saving images: it is small, has no required dependencies and handles formats, text, transparency, EXIF and colour profiles best. Use OpenCV for computer vision and video, and for heavy filtering, where it was 15× faster at a large blur here. Use pyvips for very large images and batch thumbnailing. They share NumPy arrays, so combining them is easy.
Speed on the same 15-megapixel photo
import io
import time
import warnings
import numpy as np
from PIL import Image, ImageFilter
warnings.simplefilter("ignore")
Image.open("photo.jpg").resize((4800, 3200), Image.LANCZOS).save("big.jpg", quality=90) # a 15-megapixel photo
def best(fn, n=5):
runs = []
for _ in range(n):
t = time.perf_counter(); fn(); runs.append((time.perf_counter() - t) * 1000)
return min(runs)
rows = {}
img = Image.open("big.jpg").convert("RGB")
def pil_thumb(): # open, shrink to 1200 px wide, save as JPEG
im = Image.open("big.jpg")
im.draft("RGB", (1200, 800)) # let the JPEG decoder skip what is thrown away anyway
im.thumbnail((1200, 1200), Image.LANCZOS)
im.save(io.BytesIO(), "JPEG", quality=85)
rows["Pillow"] = {
"decode": best(lambda: Image.open("big.jpg").load()),
"resize Lanczos": best(lambda: img.resize((1200, 800), Image.LANCZOS)),
"resize fastest": best(lambda: img.reduce(4)), # exact 4x shrink by averaging 4x4 blocks
"blur": best(lambda: img.filter(ImageFilter.GaussianBlur(4))),
"encode": best(lambda: img.save(io.BytesIO(), "JPEG", quality=85)),
"thumbnail pipeline": best(pil_thumb),
}
try:
import cv2
bgr = cv2.imread("big.jpg")
def cv_thumb():
a = cv2.imread("big.jpg", cv2.IMREAD_REDUCED_COLOR_4)
cv2.imencode(".jpg", cv2.resize(a, (1200, 800), interpolation=cv2.INTER_AREA), [cv2.IMWRITE_JPEG_QUALITY, 85])
rows["OpenCV"] = {
"decode": best(lambda: cv2.imread("big.jpg")),
"resize Lanczos": best(lambda: cv2.resize(bgr, (1200, 800), interpolation=cv2.INTER_LANCZOS4)),
"resize fastest": best(lambda: cv2.resize(bgr, (1200, 800), interpolation=cv2.INTER_AREA)),
"blur": best(lambda: cv2.GaussianBlur(bgr, (0, 0), 4)),
"encode": best(lambda: cv2.imencode(".jpg", bgr, [cv2.IMWRITE_JPEG_QUALITY, 85])),
"thumbnail pipeline": best(cv_thumb),
}
except ImportError:
pass
try:
import imageio.v3 as iio
import skimage.filters
import skimage.transform
arr = iio.imread("big.jpg")
def sk_thumb():
a = skimage.transform.resize(iio.imread("big.jpg"), (800, 1200), anti_aliasing=True)
iio.imwrite("<bytes>", (a * 255).astype(np.uint8), extension=".jpg", quality=85)
rows["scikit-image"] = {
"decode": best(lambda: iio.imread("big.jpg"), 3),
"resize Lanczos": None,
"resize fastest": best(lambda: skimage.transform.resize(arr, (800, 1200), anti_aliasing=True), 3),
"blur": best(lambda: skimage.filters.gaussian(arr, sigma=4, channel_axis=-1), 3),
"encode": best(lambda: iio.imwrite("<bytes>", arr, extension=".jpg", quality=85), 3),
"thumbnail pipeline": best(sk_thumb, 3),
}
except ImportError:
pass
try:
import pyvips
v = pyvips.Image.new_from_file("big.jpg").copy_memory()
rows["pyvips"] = {
"decode": best(lambda: pyvips.Image.new_from_file("big.jpg", access="sequential").copy_memory()),
"resize Lanczos": best(lambda: v.resize(0.25, kernel="lanczos3").copy_memory()),
"resize fastest": best(lambda: v.resize(0.25, kernel="linear").copy_memory()),
"blur": best(lambda: v.gaussblur(4).copy_memory()),
"encode": best(lambda: v.write_to_buffer(".jpg[Q=85]")),
"thumbnail pipeline": best(lambda: pyvips.Image.thumbnail("big.jpg", 1200).write_to_buffer(".jpg[Q=85]")),
}
except (ImportError, OSError):
pass
try:
from wand.image import Image as WandImage
with WandImage(filename="big.jpg") as w0:
def w_op(fn):
def run():
with w0.clone() as w:
fn(w)
return run
def w_thumb():
with WandImage(filename="big.jpg") as w:
w.resize(1200, 800, filter="lanczos")
w.compression_quality = 85
w.make_blob("jpeg")
rows["ImageMagick (Wand)"] = {
"decode": best(lambda: WandImage(filename="big.jpg").close(), 3),
"resize Lanczos": best(w_op(lambda w: w.resize(1200, 800, filter="lanczos")), 3),
"resize fastest": best(w_op(lambda w: w.resize(1200, 800, filter="triangle")), 3),
"blur": best(w_op(lambda w: w.gaussian_blur(sigma=4)), 3),
"encode": best(w_op(lambda w: w.make_blob("jpeg")), 3),
"thumbnail pipeline": best(w_thumb, 3),
}
except ImportError:
pass
for lib, r in rows.items():
print(f"{lib:<20}" + " | ".join(f"{k}: " + (f"{t:.1f} ms" if t is not None else "n/a") for k, t in r.items()))
Pillow decode: 34.7 ms | resize Lanczos: 135.9 ms | resize fastest: 10.2 ms | blur: 389.4 ms | encode: 32.6 ms | thumbnail pipeline: 18.1 ms
OpenCV decode: 38.7 ms | resize Lanczos: 10.0 ms | resize fastest: 3.7 ms | blur: 26.2 ms | encode: 29.7 ms | thumbnail pipeline: 18.0 ms
scikit-image decode: 113.7 ms | resize Lanczos: n/a | resize fastest: 1449.6 ms | blur: 1617.4 ms | encode: 48.0 ms | thumbnail pipeline: 1606.7 ms
pyvips decode: 45.0 ms | resize Lanczos: 16.5 ms | resize fastest: 13.2 ms | blur: 34.0 ms | encode: 37.9 ms | thumbnail pipeline: 34.3 ms
ImageMagick (Wand) decode: 113.8 ms | resize Lanczos: 72.4 ms | resize fastest: 29.4 ms | blur: 6513.6 ms | encode: 103.6 ms | thumbnail pipeline: 186.8 ms
| Library | decode (ms) | resize Lanczos (ms) | resize fastest (ms) | blur (ms) | encode (ms) | thumbnail pipeline (ms) |
|---|---|---|---|---|---|---|
| Pillow | 34.7 | 135.9 | 10.2 | 389.4 | 32.6 | 18.1 |
| OpenCV | 38.7 | 10.0 | 3.7 | 26.2 | 29.7 | 18.0 |
| scikit-image | 113.7 | – | 1449.6 | 1617.4 | 48.0 | 1606.7 |
| pyvips | 45.0 | 16.5 | 13.2 | 34.0 | 37.9 | 34.3 |
| ImageMagick (Wand) | 113.8 | 72.4 | 29.4 | 6513.6 | 103.6 | 186.8 |
Three things stand out. For the most common job, making a thumbnail, Pillow is as fast as OpenCV once it uses
draft(), because both let the JPEG decoder skip most of the pixels. On full-resolution pixels Pillow is the slower
one: a Lanczos resize took 14× as long as OpenCV's, and a large blur 15×, where pyvips is also
far faster. Shrinking by an exact factor with reduce() narrows the resize gap a lot. And scikit-image is the slowest at everything here because it
converts to floating point; its strength is its algorithms (segmentation, measurement, restoration), not speed. The
“resize fastest” column uses each library's quickest good-quality downscale (OpenCV's INTER_AREA, Pillow's
reduce()), so it compares speed at slightly different quality; the Lanczos column is like for like.
Install size
import importlib.metadata as md
import re
def installed_mb(dist, seen=None):
seen = set() if seen is None else seen
name = re.split(r"[\s;<>=!~\[]", dist, maxsplit=1)[0].lower()
if name in seen:
return 0.0
seen.add(name)
try:
files = md.files(name) or []
reqs = [r for r in (md.requires(name) or []) if "extra ==" not in r]
except md.PackageNotFoundError:
return 0.0
own = sum((f.size or 0) for f in files) / 2**20
return own + sum(installed_mb(r, seen) for r in reqs)
for label, dist in [("Pillow", "pillow"), ("OpenCV (headless)", "opencv-python-headless"),
("scikit-image", "scikit-image"), ("pyvips (with libvips)", "pyvips-binary"),
("Wand (needs ImageMagick installed)", "wand")]:
print(f"{label:<36}{installed_mb(dist):7.1f} MB installed, with its Python dependencies")
Pillow 19.5 MB installed, with its Python dependencies
OpenCV (headless) 205.8 MB installed, with its Python dependencies
scikit-image 217.8 MB installed, with its Python dependencies
pyvips (with libvips) 19.1 MB installed, with its Python dependencies
Wand (needs ImageMagick installed) 0.7 MB installed, with its Python dependencies
Pillow's wheels bundle their C libraries and need nothing else, which matters for Docker images, AWS Lambda and anything shipped to users. OpenCV pulls in NumPy and a large binary; scikit-image brings SciPy. Wand is tiny because it is only a binding: ImageMagick itself must already be installed on the system.
What each one is for
| Pillow | OpenCV | scikit-image | pyvips | ImageMagick (Wand) | |
|---|---|---|---|---|---|
| Main purpose | Image files and editing | Computer vision, video | Scientific image analysis | Large images, fast pipelines | Image conversion and effects |
| Image type | Image object | NumPy array, BGR order | NumPy array, often float | Image, evaluated lazily | Image object |
| Text with real fonts | Yes (FreeType, complex scripts) | Basic built-in fonts only | No | Yes (Pango) | Yes |
| EXIF, ICC profiles | Yes | Applies EXIF rotation; no profiles | No | Yes | Yes |
| Animated GIF/WebP | Read and write | Read and write (imreadanimation, imwriteanimation) | Through imageio | Yes | Yes |
| Video, cameras | No | Yes | No | No | No |
| Extra system software | None | None | None | None with pyvips[binary] | ImageMagick |
GPU: none of these use a GPU in their standard pip packages. For GPU work on images, use PyTorch or torchvision tensors (converting from Pillow is covered in PIL images and PyTorch tensors), or an OpenCV build compiled with CUDA.
Using Pillow and OpenCV together
import cv2
import numpy as np
from PIL import Image
img = Image.open("photo.jpg").convert("RGB")
bgr = cv2.cvtColor(np.asarray(img), cv2.COLOR_RGB2BGR) # Pillow -> OpenCV: an array, red and blue swapped
edges = cv2.Canny(bgr, 100, 200) # something only OpenCV does
back = Image.fromarray(edges) # OpenCV -> Pillow
print("edges:", back.mode, back.size, "| edge pixels:", int((np.asarray(back) > 0).sum()))
edges: L (1600, 1067) | edge pixels: 35900
A common split is Pillow for input and output (formats, EXIF rotation, text, saving) and OpenCV in the middle for analysis. The only trap is the channel order: OpenCV uses BGR. Every conversion, with the pitfalls, is in converting between Pillow and OpenCV and the conversion code generator.
Sources
What this page shows comes from running its code with Pillow 13.0.0. The API details and version history were checked against these primary sources:
- Pillow documentation: Image
- OpenCV on PyPI
- scikit-image documentation
- pyvips documentation
- Wand (ImageMagick binding) documentation
Related
The outputs and images on this page are the real results of running every example with Pillow 13.0.0 on Python 3.13 (Linux) on 2026-10-29. Every example is also re-run automatically on macOS (Darwin 25.6.0, Pillow 12.3.0), Linux (Linux 6.17.0-1022-azure, Pillow 12.3.0), Windows (Windows 2025Server, Pillow 12.3.0); the line under each example shows the result per operating system. The DejaVu Sans font files sit next to each script so font examples behave the same everywhere. Sample photos: NASA/Sam Lott, public domain. Spotted something wrong? Tell us.