Pillow Performance (2024)

Benchmarks

On this page, you'll find estimates of Pillow's performance, a comparison of Pillow's performance with Pillow-SIMD (a special performance-optimized version of Pillow), and other graphic libraries. Mainly Python libraries are tested.

Unfortunately, there is no single performance metric for these libraries. Different libraries perform operations with different efficiency and sometimes in different ways. It is only possible to measure the performance of a single operation or group of operations. For a good comparison, you need to be sure that the tested libraries give the same outcome for an operation and the same resources are used to perform the operation.

Same outcome

An operation could be performed using different algorithms. Thus, the chosen algorithm can significantly affect the result. For example, if you want to perform a resize, you can use the very fast nearest neighbor algorithm and get very poor quality. Or you can use convolution resampling and get a reasonable quality for most cases. Depending on your needs, you can or can not consider the nearest neighbor method.

In these benchmarks, we always assume that you expect results as close as possible to each other. This allows to directly compare the execution time.

Same resources

Some libraries could use more processing power than others. For example, graphics processing unit or multi-core CPUs. For some cases, this could be an advantage because it shrinks execution time. For example, if the execution time using one core is 2 seconds, the library can reduce it to 0.5 seconds using 4 cores. This library has an advantage over the library which performs the same operation in 1 second but can't use multiple cores.

However, sometimes overall throughput is more important than execution time. If you need to perform the operation on a group of images, you can do it in parallel. In this case, the first library's throughput remains the same: 2 operations per second. The second library's throughput is 4 operations per second. The second library is preferred.

In these benchmarks, we measure the throughput on single CPU core, not minimum achievable execution time.

Test suites

Libraries with Python bindings are tested using pillow-perf test suites. Each test is run 11 times and the mean execution time is calculated.

Libraries

PIL
Python Imaging Library. Initially released for Python 1.2 in 1995. Last version, 1.1.7, released on November 15, 2009. Includes image codecs and image manipulation routines.
Pillow
Python Imaging Library (fork). Originally a packaging fork, designed to facilitate more reliable installation from the Python Package Index. Starting with version 2.0 (2013), Pillow supports Python 3 and is actively maintained and developed. docs
Pillow-SIMD
Highly optimized downstream Pillow fork with performance improvements made for common operations using SIMD instructions. readme
ImageMagick
Very popular image manipulation library with bindings for many languages. Extremely flexible. In this benchmarks Wand wrapper is used. homepage
OpenCV
OpenCV aims to support real-time computer vision. Originally developed by Intel's research center, it was later supported by Willow Garage and is now maintained by Itseez. homepage
VIPS
libvips is a demand-driven, horizontally threaded image processing library. Compared to similar libraries, libvips runs quickly and uses little memory. In this benchmarks pyvips wrapper is used. homepage

Results Browser

System

    Competition

      Chart set

        Units: seconds megapixels/s operations/s

        Convolution Resampling

        Image resampling is one of the most common processing operations. Good and predictable quality can be achieved using the convolution-based method.

        "Convolution" means that for each pixel of the final image we compute some area ("window") of the source image using weights. The size of the area and weights depend on the chosen filter. There are many filters. The most common of which are:

        See Also
        Pillow

        • Bilinear — high-efficiency filter with the small window and a blurry result;
        • Bicubic — high-quality filter with medium window;
        • Lanczos — high-quality filter with large window.

        For the image downscaling the window size should be increased. This takes into account all pixels of the original image. Unfortunately, not all libraries and software do this. As a result, the output image can look extra sharp and crisp. In some cases, the result only vaguely resembles the original image.

        These are the results of resizing a 4928 × 3280pximage to 210 × 140px using different software and different filters. GoogleСhome's <canvas> implementation doesn't increase the window size on downscaling. OpenCV also doesn't do this using the Bicubic filter but it offers a supersampling resampling method.

        Pillow Performance (1)
        Pillow Performance (2)
        Pillow Performance (3)

        Obviously, it's meaningless to compare OpenCV's Bicubic performance with the correct convolution implementations. Also, supersampling is a different resampling method, not based on convolutions. Itiscorrect for downscaling but unacceptable for upscaling.

        From the very beginning, PIL also didn't increase the window size for Bilinear and Bicubic filters, but it did for Antialias (the real name of the filter is Lanczos). In Pillow 2.7.0 this was finally fixed.

        Pillow Performance (4)
        Pillow Performance (5)
        Pillow Performance (6)

        On the other hand, some image libraries do convolutions right. For example, ImageMagick. The problem with ImageMagick is that resampling is very slow. For example, it's about 20 times slower than Skia which can also do high-quality convolution resampling.

        From the very beginning, PIL and Pillow resampling performance used to be quite low and similar to ImageMagick's performance. Pillow 2.7 reverses the trend introducing several common optimizations such as loops rearrangement and cache-aware transposition.

        Charts show median performance in Megapixels/s (the lower the better) required for resizing the source 2560x1600 RGB image to one of the four destination sizes using one of the filters. For significant downsampling, Pillow 2.7 is 2—4times faster than PIL. Pillow 3.3 introduces fixed-point arithmetic for resampling which is even faster. Pillow 3.4 and 4.3 have additional optimizations for large target dimensions. In the end, current Pillow version is up to 7 times faster than the original PIL.

        But this is not the end of the story. Starting with Pillow 3.2 you can use a SIMD-enabled Pillow version. Pillow-SIMD resampling performance is significantly increased compared to Pillow. The latest Pillow-SIMD compiled with AVX2 is 4—6times faster than Pillow. In sum, Pillow-SIMD resampling performance is 12—35times higher than the original PIL.

        Gaussian Blur

        High-quality Gaussian blur can be used to reduce image noise and details. It is also used as a pre-processing stage in computer vision algorithms.

        Mathematically, applying a Gaussian blur to an image is the same as convolving the image with a Gaussian function. The amount of blur depends on standard deviation size (sigma). In theory, the Gaussian function is infinite. It means that we need to compute every pixel of the source image for every pixel in the destination image. In practice, Gaussian is a rapidly decreasing function and a window size more than 3*sigma has no meaning.

        As a result, Gaussian blur performance should depend on window size and sigma. For most implementations this is true. But in 2011 Mathematical Image Analysis Group from Saarland University proved that Gaussian blur can be very closely approximated by series of extended box filters. Unlike a true Gaussian filter, box filter can be performed in constant time relative to blur radius.

        This approach was implemented in Pillow 2.7.0. According to the tests, even if approximation with box filters could be little slower with a small sigma, with a larger sigma this gap disappears and approximation becomes much faster. SIMD gives an additional 2x boost.

        Transposition

        This is a group of operations which is most relevant when an image has an orientation flag stored in EXIF. The group includes such operations as rotating by right angles, mirroring and transposition itself. It differs from regular rotation because these operations are non-destructive (ie pixel values are not modified) and can be performed very fast.

        Mirroring and rotating by 180° are reasonably fast in most implementations. There was an issue in Pillow with rotating by 90° and 270° because those operations can consume CPU cache highly inefficiently. In Pillow 2.7 the cache-aware algorithm was implemented. Also, transposition was added.

        Color Conversion

        • RGB — General red, green, blue values
        • RGBA — RGB with alpha channel
        • RGBa — RGB values multiplied on alpha channel
        • L — luminance values (grayscale) with 1 byte per pixel
        • LA — luminance values with alpha channel

        Conversion from RGBA to RGBa can be used to normalize pixel values before resizing and other transformations.

        Compositing

        Alpha compositing is used for overlaying two semitransparent images. Unlike alpha blending, alpha compositing mixes color and alpha channels with different coefficients.

        Pillow Performance (2024)
        Top Articles
        Is Tungsten Carbide Magnetic? The Answer (may) Surprise You!
        How To Battle Together with Your Buddy in Pokemon Go and Earn a Heart
        O'reilly's Auto Parts Closest To My Location
        Winston Salem Nc Craigslist
        Readyset Ochsner.org
        ³µ¿Â«»ÍÀÇ Ã¢½ÃÀÚ À̸¸±¸ ¸íÀÎ, ¹Ì±¹ Ķ¸®Æ÷´Ï¾Æ ÁøÃâ - ¿ù°£ÆÄ¿öÄÚ¸®¾Æ
        The Best Classes in WoW War Within - Best Class in 11.0.2 | Dving Guides
        Kris Carolla Obituary
        Craigslist In Fredericksburg
        Southland Goldendoodles
        All Obituaries | Ashley's J H Williams & Sons, Inc. | Selma AL funeral home and cremation
        Hope Swinimer Net Worth
        Beau John Maloney Houston Tx
        Missed Connections Dayton Ohio
        Espn Horse Racing Results
        Billionaire Ken Griffin Doesn’t Like His Portrayal In GameStop Movie ‘Dumb Money,’ So He’s Throwing A Tantrum: Report
        Bj Alex Mangabuddy
        Toy Story 3 Animation Screencaps
        Khiara Keating: Manchester City and England goalkeeper convinced WSL silverware is on the horizon
        The Ultimate Style Guide To Casual Dress Code For Women
        R Personalfinance
        10 Fun Things to Do in Elk Grove, CA | Explore Elk Grove
        Arre St Wv Srj
        Mj Nails Derby Ct
        8005607994
        Best Sports Bars In Schaumburg Il
        Mythical Escapee Of Crete
        Accuweather Minneapolis Radar
        Colonial Executive Park - CRE Consultants
        Jailfunds Send Message
        2021 Tesla Model 3 Standard Range Pl electric for sale - Portland, OR - craigslist
        950 Sqft 2 BHK Villa for sale in Devi Redhills Sirinium | Red Hills, Chennai | Property ID - 15334774
        Page 2383 – Christianity Today
        Redbox Walmart Near Me
        Devotion Showtimes Near The Grand 16 - Pier Park
        Chapaeva Age
        Japanese Pokémon Cards vs English Pokémon Cards
        Solve 100000div3= | Microsoft Math Solver
        Murphy Funeral Home & Florist Inc. Obituaries
        Σινεμά - Τι Ταινίες Παίζουν οι Κινηματογράφοι Σήμερα - Πρόγραμμα 2024 | iathens.gr
        The Thing About ‘Dateline’
        Rochester Ny Missed Connections
        Jail View Sumter
        Ucsc Sip 2023 College Confidential
        Grand Valley State University Library Hours
        Tropical Smoothie Address
        Canada Life Insurance Comparison Ivari Vs Sun Life
        Research Tome Neltharus
        Uno Grade Scale
        O'reilly's On Marbach
        Billings City Landfill Hours
        Ark Silica Pearls Gfi
        Latest Posts
        Article information

        Author: Nathanael Baumbach

        Last Updated:

        Views: 6397

        Rating: 4.4 / 5 (55 voted)

        Reviews: 94% of readers found this page helpful

        Author information

        Name: Nathanael Baumbach

        Birthday: 1998-12-02

        Address: Apt. 829 751 Glover View, West Orlando, IN 22436

        Phone: +901025288581

        Job: Internal IT Coordinator

        Hobby: Gunsmithing, Motor sports, Flying, Skiing, Hooping, Lego building, Ice skating

        Introduction: My name is Nathanael Baumbach, I am a fantastic, nice, victorious, brave, healthy, cute, glorious person who loves writing and wants to share my knowledge and understanding with you.