Image Occlusion – Make Image Field Visible

Hello, im using AJT Media Converter / WebP, AVIF to compress images with AVIF, but image occlusion “paste from clipboard” bypasses the add-on and paste jpg.

Not sure if an add-on fix is possible, but another workaround would be to unhide the image field in the editor

Image Occlusion enhanced is an alternative, you have to manually edit every card with the compressed image, while the built-in requires changing one


2 Likes

Perhaps this PR giving more direct access to IO images will help with that?

Its more troublesome than simply unhiding the image field tbh, but ig it would work, but instead of changing in Anki, the user would require to download the avif image and open the file app to change it

For instance the workflow on basic or cloze is:

Paste image in field > AJT compress and convert image > outputs AVIF


@tatsumoto Would be possible for AJT Media to paste avif/webp in Image Occlusion?

AJT Media Converter uses gui_hooks.editor_will_process_mime. If it finds an image file in the mime data, it converts it to webp or avif depending on the settings.

I’ve heard about image occlusion before. If I’m right, it is when you have an image on the front of a flashcard and there’s a hidden piece that you need to recall. Are you talking about this addon? If so, it is possible that the add-on uses a different code path from what AJT Media Converter is designed to work with. I haven’t used it myself. If you teach me how to use it, I might be able to figure out why it doesn’t work.

NameLessGO seems to be using the build in image occlusion.

  1. Open Anki.
  2. Click on Add.
  3. Choose card type Image Occlusion.
  4. Select Image.
  5. Draw a square somewhere.
  6. Press Add button.
  7. Done.
2 Likes

Thanks, found it. Didn’t know Anki had such a feature lol. Is it intended to be used by regular users? Judging by how confusing it is, maybe it’s a hidden feature, and it’s not ready yet. However, if you press "Edit" > "AJT Media Converter: Bulk convert" then it converts the image correctly, so it’s not completely broken. The note editor is still broken though. I can only see the image in the Editor, and all fields are completely hidden. If I press “Fields”, I can see that the note has 5 fields, but none of them are shown in the Editor.

Here’s a script that can help you see the contents of a note (use the debug console to run it):

from aqt import mw
note = mw.col.get_note(1234567890123)
for field in note.keys():
    print(f"{field}: {note[field]}")
1 Like

Didn’t considered Bulk convert, Thanks!

Also learned this recently, but you have to press Toggle Mask fields button next to Cloze and the remaining fields will appear
image

1 Like

Thanks for the tip! I can’t believe it’s so difficult to use. Why don’t just show the other fields under the image…

Apparently, when you press “paste image from clipboard”, Anki runs the function select_image_from_clipboard_and_occlude() and doesn’t call gui_hooks.editor_will_process_mime(). So I’m assuming the hook should be called after this line, but it is not:

And when you press “select image”, Anki runs select_image_and_occlude().

There’s a method setup_mask_editor(). I think if AJT Media Converter wraps it, it could be sufficient to intercept and convert images before they’re shown.