ipynbcompress


Nameipynbcompress JSON
Version 0.5.0 PyPI version JSON
download
home_pagehttps://github.com/arve0/ipynbcompress
SummaryCompress images in IPython/Jupyter notebooks
upload_time2023-07-16 10:16:17
maintainer
docs_urlNone
authorArve Seljebu
requires_python
licenseMIT
keywords ipynbcompress
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ipynbcompress
=============

|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 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``\ …

.. code:: bash

   pip install ipynbcompress

Example
-------

From command line:

.. code:: sh

   $ 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:

.. code:: 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:

.. code:: bash

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

Testing
~~~~~~~

.. code:: bash

   pytest

Build documentation locally
~~~~~~~~~~~~~~~~~~~~~~~~~~~

To build the documentation:

.. code:: bash

   pip install -r docs/requirements.txt
   make docs

.. |build-status-image| image:: https://github.com/arve0/ipynbcompress/actions/workflows/main.yml/badge.svg
   :target: https://github.com/arve0/ipynbcompress/actions/workflows/main.yml
.. |pypi-version| image:: https://img.shields.io/pypi/v/ipynbcompress.svg
   :target: https://pypi.python.org/pypi/ipynbcompress
.. |wheel| image:: https://img.shields.io/pypi/wheel/ipynbcompress.svg
   :target: https://pypi.python.org/pypi/ipynbcompress

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/arve0/ipynbcompress",
    "name": "ipynbcompress",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "ipynbcompress",
    "author": "Arve Seljebu",
    "author_email": "arve.seljebu@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/fc/4c/14fa91d45f713bcaf8a6e65e54f9eebee19bc4a465e1be12032b641787f8/ipynbcompress-0.5.0.tar.gz",
    "platform": null,
    "description": "ipynbcompress\n=============\n\n|build-status-image| |pypi-version| |wheel|\n\nOverview\n--------\n\nSo you have included an image with ``IPython.display.Image()`` and the\nfile size of your IPython Notebook got huge? No problem! This package\nwill resize images in your notebook and compress them as PNG or JPEG.\nImages are only resized if they are above the specified width. 2048px\nand PNG compression is the default, which should give relative high\nquality images and normal sized notebooks. JPEG compression is nice if\nyou serve the notebooks over the web (eg nbviewer) and prefer fast\nloading times.\n\nInstallation\n------------\n\nInstall using ``pip``\\ \u2026\n\n.. code:: bash\n\n   pip install ipynbcompress\n\nExample\n-------\n\nFrom command line:\n\n.. code:: sh\n\n   $ ipynb-compress notebook4.ipynb\n   notebook4.ipynb: 10 megabytes decrease\n   $ find . -name \"*ipynb\" -size +2M -exec ipynb-compress {} \\;\n   ./lab 03.21/automated scan.ipynb: warning: no compression - 0 bytes gained\n   ./lab 03.21/automated scan.ipynb: compression less than 100k bytes - keeping original\n   ./lab 03.21/trouble.ipynb: 9 megabytes decrease\n   ...\n\nIn python:\n\n.. code:: python\n\n   >>> import os\n   >>> from ipynbcompress import compress\n   >>> filename = '/path/to/notebook.ipynb'\n   >>> out = '/path/to/compressed.ipynb'\n   >>> # original size\n   ... os.stat(filename).st_size\n   11563736\n   >>> # return bytes saved\n   ... compress(filename, output_filename=out, img_width=800, img_format='jpeg')\n   11451545\n   >>> compress(filename, output_filename=out, img_width=800, img_format='png')\n   11205762\n   >>> # defaults to img_width = 2048px and png compression\n   ... compress(filename, output_filename=out)\n   11411377\n   >>> # overwrite existing notebook\n   ... compress(filename)\n   11411377\n\nAPI reference\n-------------\n\nAPI reference is at http://ipynbcompress.rtfd.org.\n\nDevelopment\n-----------\n\nInstall dependencies and link development version of ipynbcompress to\npip:\n\n.. code:: bash\n\n   git clone https://github.com/arve0/ipynbcompress\n   cd ipynbcompress\n   pip install -r requirements.txt # install dependencies and ipynbcompress-package\n\nTesting\n~~~~~~~\n\n.. code:: bash\n\n   pytest\n\nBuild documentation locally\n~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nTo build the documentation:\n\n.. code:: bash\n\n   pip install -r docs/requirements.txt\n   make docs\n\n.. |build-status-image| image:: https://github.com/arve0/ipynbcompress/actions/workflows/main.yml/badge.svg\n   :target: https://github.com/arve0/ipynbcompress/actions/workflows/main.yml\n.. |pypi-version| image:: https://img.shields.io/pypi/v/ipynbcompress.svg\n   :target: https://pypi.python.org/pypi/ipynbcompress\n.. |wheel| image:: https://img.shields.io/pypi/wheel/ipynbcompress.svg\n   :target: https://pypi.python.org/pypi/ipynbcompress\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Compress images in IPython/Jupyter notebooks",
    "version": "0.5.0",
    "project_urls": {
        "Homepage": "https://github.com/arve0/ipynbcompress"
    },
    "split_keywords": [
        "ipynbcompress"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1e96b0b36d0561e96b3eaa81484a423b471857830380d114ad57b62b6d058291",
                "md5": "12b91ad2adb66c5f3d8b5ffea3d39bbb",
                "sha256": "26b6b983aaf4f8c3fbff53431e23525bcae08d3edef5191a8b4d70238b6f5b7e"
            },
            "downloads": -1,
            "filename": "ipynbcompress-0.5.0-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "12b91ad2adb66c5f3d8b5ffea3d39bbb",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 5976,
            "upload_time": "2023-07-16T10:16:13",
            "upload_time_iso_8601": "2023-07-16T10:16:13.163346Z",
            "url": "https://files.pythonhosted.org/packages/1e/96/b0b36d0561e96b3eaa81484a423b471857830380d114ad57b62b6d058291/ipynbcompress-0.5.0-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fc4c14fa91d45f713bcaf8a6e65e54f9eebee19bc4a465e1be12032b641787f8",
                "md5": "3f2a902272c71c27d86ab98ab66a9bab",
                "sha256": "b14de8f470a482c841e02186e7d1b5516211553ffa3646ac0f4c253094a5917d"
            },
            "downloads": -1,
            "filename": "ipynbcompress-0.5.0.tar.gz",
            "has_sig": false,
            "md5_digest": "3f2a902272c71c27d86ab98ab66a9bab",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 8384555,
            "upload_time": "2023-07-16T10:16:17",
            "upload_time_iso_8601": "2023-07-16T10:16:17.712487Z",
            "url": "https://files.pythonhosted.org/packages/fc/4c/14fa91d45f713bcaf8a6e65e54f9eebee19bc4a465e1be12032b641787f8/ipynbcompress-0.5.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-07-16 10:16:17",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "arve0",
    "github_project": "ipynbcompress",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "ipynbcompress"
}
        
Elapsed time: 0.20346s