Kanji Colorizer: Stroke Order Diagrams [Official Support Thread]


This is the official support thread for https://ankiweb.net/shared/info/1964372878 .

I don’t know if this is the correct way to start a topic.

My question is, suddenly the colorizer add-on is creating stroke order diagrams for kana. I only want it for kanji, which is how it used to be. Is there a way to turn off the kana aspect? Thanks.

There isn’t, but I’ll add a config option for that in the next release.


I’ve just uploaded a version with this change. In addition to the current behavior, you can configure it to never generate diagrams for anything but kanji or to always generate diagrams for all characters.

Works like a charm - thanks!

Installed the add-on and did multi restarts.
Stroke Kanji is not showing up in Diagram field.
Running on MacOS Catalina 10.15.6

Does this happen both when editing the card (it doesn’t update until you leave the field) and when using the menu items?

More information that might be helpful: what version of anki and what version of kanjicolorize are you running? Can you post your full config for kanji colorize and the name of the model and its source and destination fields?

the addon suddenly stops working.

Hello, I’ve been running into this error, I haven’t touched the addon files at all. I tried restarting anki and creating a new profile with just my kanjis deck but neither made the error go away. Help would be appreciated!

Debug info:
Anki 2.1.34 (8af8f565) Python 3.8.0 Qt 5.15.1 PyQt 5.15.1
Platform: Windows 10
Flags: frz=True ao=True sv=2
Add-ons, last update check: 2020-10-08 22:53:25

Caught exception:
Traceback (most recent call last):
File “C:\Users\Gooifgeffpawkek\AppData\Roaming\Anki2\addons21\1964372878\kanji_colorizer.py”, line 189, in generate_for_new
for note_id in mw.col.findNotes(search_str):
File “anki\collection.py”, line 453, in find_notes
File “anki\rsbackend_gen.py”, line 88, in search_notes
File “anki\rsbackend.py”, line 267, in _run_command
anki.rsbackend.InvalidInput: Invalid search - please check for typing mistakes.

This can happen if there aren’t any models that match your config. Have you checked your source, destination, and model settings?

I just released a version with a better message in this case.

Besides the above error message, the newly released version also includes a user contribution with a setting to not overwrite the destination field if it already has something in it.

I can’t help without more specific information. What are you trying to do? What is happening instead? What changed between when it was working and when it wasn’t working.

Hello! I just installed this addon, and I’m having a problem with getting the stroke order diagram to show up in a card. It doesn’t show up in Browse>Card customization, or when I try to actually study the card. I followed (to my knowledge) all the directions on how to add the stroke order diagram (with how everything should be named an such) and it shows up and seems to work fine during the process of creating a new card, just not as I mentioned above. I have tried restarting Anki.

I’m on Windows 10 with Anki Version ⁨2.1.37. I’m not sure which version of the add-on, but I guess the latest as of December 14th, 2020, as I downloaded it today? (I’m slightly tech illiterate, so I’m very sorry if there’s something obvious I missed.)

Hi. It sounds like maybe you just haven’t generated diagrams for your existing cards. That’s at tools > kanji colorize > generate all new.

Hi - I’ve made some modifications to the code so that the config src and dest fields don’t have to be exactly spelled out (used the ‘in’) keyword. Also, allowed there to be multiple diagram fields so that each kanji in a compound can be written to a different field. Are you interested in seeing my modifications?

Thanks, yes those do sound potentially useful to other people.

I’ve attached the file I made the changes in, let me know if you have any

(Attachment kanji_colorizer.py is missing)

I’ve attached the file with my changes, apologies for the delay! I had tried to just attach it without modifying the file extension, but that was rejected by the mail server.

(Attachment kanji_colorizer-multidiag.txt is missing)

Because the forums won’t allow txt or py attachments, I’m copying and pasting my changes in - hopefully with enough context that you can tell where they go

from kanjicolorizer.colorizer import (KanjiVG, KanjiColorizer,
import string
import re

srcField = ‘(word.Kanji.)’
dstField = ‘(.iagram.)’

model_name = model[‘name’].lower()
dstMatch = None
srcMatch = None
for name in mw.col.models.fieldNames(model):
if dstMatch == None:
dstMatch = re.match(dstField,name,re.IGNORECASE)
if srcMatch == None:
srcMatch = re.match(srcField,name,re.IGNORECASE)
if dstMatch != None and srcMatch != None:

return (‘kanji’ in model_name and srcMatch and dstMatch)

if currentFieldIndex != None: # We’ve left a field

But it isn’t the relevant one

match = re.match(srcField,note.model()[‘flds’][currentFieldIndex][‘name’],re.IGNORECASE)
if match == None:
return None
else: #We’re regenerating so need to find the src field
for name in mw.col.models.fieldNames(note.model()):
match = re.match(srcField,name,re.IGNORECASE)
if match:
srcTxt = mw.col.media.strip(note[match.group(1)])

destinationNames =[]
for name in mw.col.models.fieldNames(note.model()):
dstMatch = re.match(dstField,name,re.IGNORECASE)
if dstMatch != None:

destIndex = 0
dst = ‘’
for character in characters_to_colorize(unicode(srcTxt)):

write to file; anki works in the media directory by default

filename = KanjiVG(character).ascii_filename
except InvalidCharacterError:

silently ignore non-Japanese characters

char_svg = kc.get_colored_svg(character).encode(‘utf_8’)
anki_fname = mw.col.media.writeData(unicode(filename, ‘utf_8’), char_svg)
strokeFileName = ‘’.format(anki_fname).encode(‘utf_8’)
if len(destinationNames) > 1:
note[destinationNames[destIndex]] = strokeFileName
destIndex += 1
flag = True
dst += strokeFileName
note[destinationNames[0]] = dst
flag =True

return flag

Hope this finally gets to you, apologies for the delay