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 support for base64 images #56

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

smor
Copy link

@smor smor commented Jul 13, 2022

This partly closes #55.

What it does

This adds support to render images as base64 data instead of a URL in the XML file. It implements a --images-base64 command-line toggle defaulting to False. This would produce code like <img src="data:image/jpeg;base64,/9j/<base64 data>"/> instead of <img src="%24IMS-CC-FILEBASE%24/images/trex.jpeg"/>.

Lack of base64 image support in LMSes

After thorough evaluation, it does not appear that either Canvas LMS or D2L's BrightSpace, which is my prime target platform, support base64 images well. In more details:

  • Canvas LMS does not appear to provide any support whatsoever for base64 images, be it in manual editing or in importing quiz data;
  • BrightSpace does support base64 image data in manual editing, although it creates a file and links to it upon save. It does not, however, provide the same service when importing a quiz ZIP file. This would have been sufficient for my use case.

Potential uses

As is it, I fail to see practical value for my own use case and for Canvas LMS users in this very pull request. However, it may be used in another LMS platform with better support for base64 images. It may also be used as a base for improvements or further investigation by interested parties.

To do

The mime-type is hard-coded to jpeg in this PR, as I did not see real interest in going further for the aforementioned reasons. To make it usable, one would need to detect the images' mime-types, using the filetype Python package for instance.

One could also use PIL to convert image files to base64 directly, and then be able to properly handle resizing at the image data level (not the CSS level) and other neat features, but that would add quite a large dependency.

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

Successfully merging this pull request may close these issues.

Add support for base64 images
1 participant