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 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.
Installation
Install using pip…
pip install ipynbcompress
Example
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
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 = 2048px and png 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
pytest
Build documentation locally
To build the documentation:
pip install -r docs/requirements.txt
make docs
Metadata
Release files for ipynbcompress 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| ipynbcompress-0.4.0.tar.gz | 8.4 MB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ipynbcompress-0.4.0-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details |
Total release size: 8.4 MB
Release files / ipynbcompress-0.4.0.tar.gz
| Download URL | ipynbcompress-0.4.0.tar.gz |
|---|---|
| Size | 8.4 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d351b8463cd3f52861ee571f81b8e30752a39c5b7d1bb8607253e256a46c1bfd
|
|
BLAKE2b-256 checksum How to use checksums |
b46a75df36459e181f17f566f157ecebc320293e9fb3f9233f258e942ae3783f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.16
|
Release files / ipynbcompress-0.4.0-py2.py3-none-any.whl
| Download URL | ipynbcompress-0.4.0-py2.py3-none-any.whl |
|---|---|
| Size | 5.9 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
c40954b20b617e67361e4eb89f6ec380c072cba650a29bd2f8e51287b1f3425f
|
|
BLAKE2b-256 checksum How to use checksums |
a64ca5f70578b865aadb8e7ba8f2c0ca5de789003148e0d0886868d7af968bfc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.16
|
Security for ipynbcompress 0.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.