Compress images in IPython/Jupyter notebooks
Project description
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
From command line:
$ ipynb-compress notebook4.ipynb
notebook4.ipynb: 10 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
11563736
>>> # return bytes saved
... compress(filename, output_filename=out, img_width=800, img_format='jpeg')
11451545
>>> compress(filename, output_filename=out, img_width=800, img_format='png')
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.2.1.tar.gz
(8.4 MB
view details)
Built Distribution
File details
Details for the file ipynbcompress-0.2.1.tar.gz
.
File metadata
- Download URL: ipynbcompress-0.2.1.tar.gz
- Upload date:
- Size: 8.4 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8dd6323122ba70020a83a222f6a7704b5a5e87fde572d61f2947ea2370b9b924 |
|
MD5 | 4944052352a20bc5a6d7e75ee03afa59 |
|
BLAKE2b-256 | a6944226be8be4cfc0ce9bb1b633e689cf9a384fed5164c61e04c61f16f72b02 |
File details
Details for the file ipynbcompress-0.2.1-py2.py3-none-any.whl
.
File metadata
- Download URL: ipynbcompress-0.2.1-py2.py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9039d7327a404873e31f2d45e720035a34903567aa4a5001b2d76ba45165b1e8 |
|
MD5 | cb5e9e4c5aa3dfc7fb43f1b9a42a5972 |
|
BLAKE2b-256 | 453cf5d1578a07a615d54c5bafe091c6f87ee48444bed59c5d49c7baf76506c9 |