Skip to content

musically-ut/anki-slides-import

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

70 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

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

  • Q: - Include the succeeding text as a standalone question without a slide (default behaviour without slide modifiers).
  • Q_S: - Include the succeeding text as a question followed by the current slide.
  • S_Q: - Include the current slide followed by the succeeding text as a question.
  • A: - Include the succeeding text as a standalone answer without a slide.
  • A_S: - Include the succeeding text as an answer followed by the current slide.
  • S_A: - Include the current slide followed by the succeeding text as an answer.

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:

  • a or w - 'All' of the slide, or the 'whole' of the slide (Numerical: [[0:100], [0:100]]).
  • t or th - 'Top' or 'top half' of the slide (Numerical: [[0:100], [0:50]]).
  • vmh - 'Vertical middle half' of the slide (Numerical: [[0:100], [25:75]]).
  • b or bh - 'Bottom' or 'bottom half' of the slide (Numerical: [[0:100], [50:100]]).
  • l or lh - 'Left' or 'left half' of the slide (Numerical: [[0:50], [0:100]]).
  • mh or hmh - 'Middle half' or 'horizontal middle half' of the slide (Numerical [[25:75], [0:100]]).
  • r or rh - 'Right' or 'right half' of the slide (Numerical: [[50:100], [0:100]]).
  • m or c or mq or cq - 'Middle' or 'centre' or 'middle quarter' or 'centre quarter' of the slide (Numerical: [[25:75], [25:75]]).
  • tl or tlq - 'Top-left' or 'top-left quarter' of the slide (Numerical: [[0:50], [0:50]]).
  • tr or trq - 'Top-right' or 'top-right quarter' of the slide (Numerical: [[50:100], [0:50]]).
  • bl or blq - 'Bottom-left' or 'bottom-left quarter' of the slide (Numerical: [[0:50], [50:100]]).
  • br or brq - 'Bottom-right' or 'bottom-right quarter' of the slide (Numerical: [[50:100], [50:100]]).
  • tt - 'Top third' of the slide (Numerical: [[0:100], [0:33]]).
  • vmt - 'Vertical middle third' of the slide (Numerical: [[0:100], [33:66]]).
  • bt - 'Bottom third' of the slide (Numerical: [[0:100], [66:100]]).
  • lt - 'Left third' of the slide (Numerical: [[0:33], [0:100]]).
  • mt or hmt - 'Middle third' or 'horizontal middle third' of the slide (Numerical: [[33:66], [0:100]]).
  • rt - 'Right third' of the slide (Numerical: [[66:100], [0:100]]).
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

  • Allow markdown in the slide notes

Acknowledgements

  • @barryridge for major changes to parsing of notes file.