Junix is a simple python package to export images from a Jupyter Notebook.
Given a notebook like the one below, Junix can export its images into separate files.
Alternatively, it can extract notebook images alongside their associated context and store them into a dictionary list leaving further processing in the hands of the user.
pip install junix
git clone https://github.com/damienmarlier51/JupyterNotebookImageExporter.git
cd JupyterNotebookImageExporter; python setup.py install
junix.export_images(filepath=filepath, output_dir=output_dir, prefix=prefix)
Parameters:
filepath: Notebook filepath
output_dir (Optional): Default value is current directory (pwd)
prefix (Optional): Default value is notebook filename
images = junix.get_images(filepath=filepath)
Parameters:
filepath: Notebook filepath
images
will have the following schema:
images = [{
"cell_idx": cell_idx, # Cell index
"output_idx": output_idx, # Output index
"content_type": content_type, # Content type
"img_data": img_data # Image data
}, ...]
junix --filepath /path/to/notebook --output_dir path/to/output/directory --prefix my_prefix
junix -f /path/to/notebook -o path/to/output/directory -p my_prefix
Example can be found example/example.ipynb
.
You can test the python API by running the following command from root directory:
python -m example.export_example
It will export images into folder example/example_images_1
.
You can test as well the CLI by running the following command from root directory:
junix -f example/example.ipynb -o example/example_images_2 -p nb
It will export images into folder example/example_images_2
.
Run pytest
from root directory
Medium blog post: https://medium.com/analytics-vidhya/export-images-from-jupyter-notebook-with-a-single-command-422db2b66e92