Skip to main content

Compress images in IPython/Jupyter notebooks

Project description

build-status-image pypi-version wheel

Overview

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 JPG or PNG.

Installation

Install using pip

pip install ipynbcompress

Example

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

API reference

API reference is at http://ipynbcompress.rtfd.org.

Development

Install dependencies and link development version of ipynbcompress to pip:

git clone https://github.com/arve0/ipynbcompress
cd ipynbcompress
pip install -r requirements.txt # install dependencies and ipynbcompress-package

Testing

tox

Build documentation locally

To build the documentation:

pip install -r docs/requirements.txt
make docs

Project details


Download files

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

Source Distribution

ipynbcompress-0.1.1.tar.gz (8.4 MB view details)

Uploaded Source

Built Distribution

ipynbcompress-0.1.1-py2.py3-none-any.whl (5.4 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file ipynbcompress-0.1.1.tar.gz.

File metadata

File hashes

Hashes for ipynbcompress-0.1.1.tar.gz
Algorithm Hash digest
SHA256 af1069c2031c12573fd36599b439cf970e51c4cacb51478eb4bbd8fc40ea462c
MD5 e9f9cfc70c55fecb93282bf52dfc53d7
BLAKE2b-256 c84a0c497fb49d25dd8f34cca5a1ccb3d899799909d65162e260f6ee507b84ca

See more details on using hashes here.

File details

Details for the file ipynbcompress-0.1.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for ipynbcompress-0.1.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 a9c7b52a636ed20674be475267996693e475f507cdc9428017842cafb9c1c8d0
MD5 c84dd51221ab54aae3890515171c0eba
BLAKE2b-256 a1efe4600d2542cd0be5ea33eabc836a23c2e5f92e8a1fcf4b7195d08f486ece

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page