Export unmasked image to anki?

Hello,

I am trying to use the image occlusion enhanced as a custom template and would like to have the “toggle masks” feature in Anki remove all clozes. Here is an example from Anki:

The template looks like this:

The masks are .svg images:

9290d7ffe9294dd9a631b237f3536824-ao-1-A

As I see it, this would require the following additional export fields in the custom template exporter:

  1. Export Image only
  2. Export Question Mask Only (.svg)
  3. Export Answer Mask Only (.svg)
  4. Export Original Mask Only (.svg)

Please let me know if there is another way to achieve what I am trying to do :slight_smile:

Hello Support,

Any suggestions here?

Hello

“use the image occlusion enhanced as a custom template”

Hello, sorry for the late reply. Do you mean just exporting the images without these masking blocks? If you use the emphasis feature in your images, these occlusions are not removable.

Kind Regards,
MarginNote-Edward
Support Team

Hi,

Whatever I have to do to use the ”toggle masks“ button to show all (see gif). I use the emphasis feature.

Of course, there is also the topic of an srs system within the app, which would forego my having to export to anki :wink:image

Hi Edward / Support,

Any suggestions on the above?

Nate

Hello

I'm not quite sure how the button is implemented, but I recommend you check the image occlusion enhanced javascript code in the anki card template, you may be able to find the corresponding move to the MN template to implement it.

Kind Regards,
MarginNote-Edward
Support Team

Hi Edward,

Thanks for getting back to me. So far as I can see there are a couple of things preventing this from happening:

  • No option for exporting the image only (only a clozed/masked image can be exported)
  • No options for exporting the masks as shown above

Please let me know if I am wrong. Here is the code for the back of the card which has the button:
Image occlusion enhanced - back.txt (1.6 KB) , but I’m not sure how to find the corresponding move:

{{#Image}}

{{Header}}
{{Answer Mask}}
{{Image}}
{{#Footer}}
{{Footer}}
{{/Footer}} Toggle Masks
{{#Remarks}}
Remarks
{{Remarks}}
{{/Remarks}} {{#Sources}}
Sources
{{Sources}}
{{/Sources}} {{#Extra 1}}
Extra 1
{{Extra 1}}
{{/Extra 1}} {{#Extra 2}}
Extra 2
{{Extra 2}}
{{/Extra 2}}

{{/Image}}

Hello Support / Edward,

Suggestions here? As MN does not support an SRS flashcard system a correct Anki export is the only way that I can see to complete this workflow…

Hello

Not the field names in the template, it should be this javascript code. But I don't know if this code works for Marginnote3's templates.

<script>
// Toggle answer mask on clicking the image
var toggle = function() {
  var amask = document.getElementById('io-overlay');
  if (amask.style.display === 'block' || amask.style.display === '')
    amask.style.display = 'none';
  else
    amask.style.display = 'block'
}

// Prevent original image from loading before mask
aFade = 50, qFade = 0;
var mask = document.querySelector('#io-overlay>img');
function loaded() {
    var original = document.querySelector('#io-original');
    original.style.visibility = "visible";
}
if (mask === null || mask.complete) {
    loaded();
} else {
    mask.addEventListener('load', loaded);
}
</script>

Kind Regards,
MarginNote-Edward
Support Team

So… What do I do with this code? Paying, OCR subscribing customer here, not developer… :man_shrugging:

Nateoh, if the feature you need is a “toggle” button, the author of ImageOcclusion Glutamate, has used this piece of JavaScript in the Anki template to implement it.

The challenge is how to use this code in the MN template. I have documented your requirements and it will take time to figure out how them work. If we can get some help or information from Glutamate or the Anki forum, we can get this feature implemented faster.

Regards.

Img-occlusion.apkg (4.3 KB)

Hi Edward

Template attached. Try it. As in the images above, I see the button on export from mn / import to anki so I don’t see this being the issue. The issue is that when I press the “Toggle masks” button, the masks are not removed (I can’t see the whole image).

The issue as I see it comes from the fact that mn exports the masks differently to the way that the image occlusion template expects them.

For example, from what I can see there is no way to export an unmasked image, which from what I can see is a large (but not complete) part of the problem. Even just this might fix the issue, but I would need to test it to see.

This is quite widely used by the way - I think the main image occlusion (Cloze) tool for Anki. So I’m sure that a lot of users would benefit from more custom export functionality in mn. :wink:

Hello Edward / Support,

Looking forward to your response on the above :wink:

Hello

Edward,这个麻烦你帮忙处理一下啦,谢谢

Kind Regards,
MarginNote-Sushi
Support Team

I’m not familiar with the exact mechanic of image occlusion(should be python?) nor with JavaScript so it’ll take some time, but when/if I find something I’ll post here.

Regards.

Thanks Edward. To be honest after this long with my above level perseverance I don’t expect much…

You guys have a great product. You also sound under-resourced. Sounds to me like you need to expand from the apple ecosystem and China to grow. Otherwise… :grimacing:

I guess its risky but if you sort out some technical issues and crack the western market I think you have the potential to do really well.

Email me if I can help with that :wink::+1: