Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Compress images in IPython/Jupyter notebooks

Project Description


So you have included an image with IPython.display.Image() and the file size of your IPython Notebook got huge? No problem! This package will resize images in your notebook and compress them as PNG or JPEG. Images are only resized if they are above the specified width. 2048px and PNG compression is the default, which should give relative high quality images and normal sized notebooks. JPEG compression is nice if you serve the notebooks over the web (eg nbviewer) and prefer fast loading times.


Install using pip

pip install ipynbcompress


From command line:

$ ipynb-compress notebook4.ipynb
notebook4.ipynb: 10 megabytes decrease
$ find . -name "*ipynb" -size +2M -exec ipynb-compress {} \;
./lab 03.21/automated scan.ipynb: warning: no compression - 0 bytes gained
./lab 03.21/automated scan.ipynb: compression less than 100k bytes - keeping original
./lab 03.21/trouble.ipynb: 9 megabytes decrease

In python:

>>> import os
>>> from ipynbcompress import compress
>>> filename = '/path/to/notebook.ipynb'
>>> out = '/path/to/compressed.ipynb'
>>> # original size
... os.stat(filename).st_size
>>> # return bytes saved
... compress(filename, output_filename=out, img_width=800, img_format='jpeg')
>>> compress(filename, output_filename=out, img_width=800, img_format='png')
>>> # defaults to img_width = 2048px and png compression
... compress(filename, output_filename=out)
>>> # overwrite existing notebook
... compress(filename)

API reference

API reference is at


Install dependencies and link development version of ipynbcompress to pip:

git clone
cd ipynbcompress
pip install -r requirements.txt # install dependencies and ipynbcompress-package



Build documentation locally

To build the documentation:

pip install -r docs/requirements.txt
make docs
Release History

Release History

This version
History Node


History Node


History Node


History Node


History Node


History Node


Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
ipynbcompress-0.3.0-py2.py3-none-any.whl (6.6 kB) Copy SHA256 Checksum SHA256 3.4 Wheel May 2, 2015
ipynbcompress-0.3.0.tar.gz (8.4 MB) Copy SHA256 Checksum SHA256 Source May 2, 2015

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting