Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added base64 image extraction feature in markdown conversion #2207

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

g3m3n30
Copy link

@g3m3n30 g3m3n30 commented Feb 14, 2025

Title: added base64 image extraction in the ipynb files

Problem

When converting notebooks to markdown, the current implementation has issues with:

  • base64 embedded images are not exported and left as it is. Only images linked with files or within ipynb are extracted.
  • it leads to markdown files with base64 images not being rendered in some reader.
  • Only IDEs can render it afaik.
  • 0ther markdown readers (iA readers, marktext ...) can't render the base64 image inside the md files. which leads to

Solution

  • Added extraction of base64 embedded images as their original format (jpg, png, ...)

  • and replaced the base64 image as directory in the new markdown file,

example
-image.png, instead of
![image.png](data:image/png;base64,iVBORw0KGgoAAAA...]

  • Duplicate filename conflicts occured when also extracting base64 images -> Added timestamp to ensure unique filenames and improved output directory path handling

Testing

  • Tested with notebooks containing multiple images, with
  • test file "notebook_with_base64.ipynb" inside test/file and
  • test_extractbase64images.py for checking it.
  • Verified correct image path resolution

Related Issues

Fixes issue with duplicate filenames and image path resolution in markdown export (likely caused by additional extraction of base64 images)

side note

  • This is my very first time for a pull request, so please bear with me and guide me if i'm not following standard practice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants