musically-ut / anki-slides-import

📇 Import pdf slides + text notes into Anki.
MIT License
25 stars 4 forks source link
anki python slide-insertion slide-modifiers slide-notes

anki-slides-import

Import pdf slides + text notes into Anki.

Convert:

Slides and notes

to:

Anki deck

Usage

  1. Use pip to install it on your system:

    pip install git+https://github.com/musically-ut/anki-slides-import
  2. Write your notes slide by slide in a plain text file.

  3. Obtain the slides in pdf format.

  4. Run slides2anki <notes.txt> <slides.pdf> <output.deck.name>.

    • Currently, you need to add -U "~/Library/Application Support/Anki2/User 1/" (or -U "~/Documents/Anki/User 1") to explicitly provide you user profile folder.
    • If you cloned this repository, then replace slides2anki with ./slides_import.py while in the repository root.
  5. Open Anki and import the <output.deck.name> as a CSV file.

The deck should be ready to use.

Slide Modifiers

The test/example_notes_q_and_a.txt file provides examples of how to use slide modifiers to alter the behaviour of Anki card generation and slide insertion. The available slide modifiers come in two varieties that allow for various forms of either slide insertion or slide cropping respectively, and are listed as follows:

Slide Insertion

Slide Cropping

Cropping with alphabetical codes

This is probably the most convenient way to crop slides. Four of the above slide insertion modifiers, Q_S:, S_Q:, A_S: and S_A:, can be amended by including codes in square brackets before the colon, like t for "top", that would crop the top half of the slide, e.g. Q_S[t]:. The full list of possible alphabetical cropping codes are as follows:

Cropping with numerical values

Alternatively, for finer control, the cropping values may be specified numerically as percentages, by amending the slide insertion codes with [[wmin:wmax], [hmin:hmax]] (or [[wmin-wmax], [hmin-hmax]]) codes before the colon, e.g. A_S[[25:5], [0:100]]: (or A_S[[25-5], [0-100]]:).

Dependencies

You may have to install ImageMagick for your system separately.

If you want to develop this tool, you can set up the dependencies required by the files by running the following:

pip install -r requirements.txt

Why is this not an Anki addon

The reason this is not available as an addon for Anki is because only 32 bit binaries are distributed for Anki and that makes it impossible to use 64-bit ImageMagick libraries. Also, it is tricky to install the 32 bit libraries for ImageMagick using the standard tools (at least on Mac with homebrew).

If I release an addon, then it will run if one checks-out and runs Anki from source (./runanki from the terminal). The version from source will use and update the database used by the system-wide Anki version. However, if one is willing to go through the trouble of doing that, then one might as well use this tool from the command line.

Help

Use slides2anki -h to see advanced help on command line options.

Why?

I made this with two use cases in mind:

  1. Some concepts are easier to understand in images and extracting images from pdfs to put in cards is cumbersome.
  2. This will allow one to take notes slide by slide in class and then directly import them into Anki.

Next steps

Acknowledgements