# How can i set auto zoom into masked area of image (card made withImage Occlusion Enhanced) )

**URL:** <https://forums.ankiweb.net/t/how-can-i-set-auto-zoom-into-masked-area-of-image-card-made-withimage-occlusion-enhanced/25497>\
**Category:** Help\
**Created:** [December 19, 2022, 7:41am UTC](https://forums.ankiweb.net/t/how-can-i-set-auto-zoom-into-masked-area-of-image-card-made-withimage-occlusion-enhanced/25497 "2022-12-19T07:41:01Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![tushar20sharma](https://avatars.discourse-cdn.com/v4/letter/t/cdc98d/32.png) [@tushar20sharma](https://forums.ankiweb.net/u/tushar20sharma)\
**Post date:** [December 19, 2022, 7:41am UTC](https://forums.ankiweb.net/t/how-can-i-set-auto-zoom-into-masked-area-of-image-card-made-withimage-occlusion-enhanced/25497/1 "2022-12-19T07:41:01Z")

</div>

i have fairly large image when making card with Image Occlusion Enhanced , now when i press study button , the image show up but because it is large , it is not readable . any way so that anki will automatically zoom into part of image where i have masked image . if this can be done please suggest how

---

<div class="post-metadata">

**Author:** ![kleinerpirat](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/kleinerpirat/32/19863_2.png) [@kleinerpirat](https://forums.ankiweb.net/u/kleinerpirat)\
**Post date:** [December 19, 2022, 5:41pm UTC](https://forums.ankiweb.net/t/how-can-i-set-auto-zoom-into-masked-area-of-image-card-made-withimage-occlusion-enhanced/25497/2 "2022-12-19T17:41:50Z")

</div>

This script may still work:

> [@Image Occlusion Enhanced \[Official Support Thread\]](https://forums.ankiweb.net/t/image-occlusion-enhanced-official-support-thread/924/57):
>
> I rewrote the script a bit. It fetches the SVG code from the image src, creates a dummy copy and inserts it as overlay, scrolls to the active occlusion and then removes the dummy again. /\*\* Auto-scroll for Image Occlusion Enhanced \* @author Matthias Metelka \<github.com/kleinerpirat\> \*/ (async function () { const img = document.querySelector("#io-overlay\>img"); const file = await fetch(img.src); const mask = new DOMParser() .parseFromString(await file.text(), "image/svg+xml") …

---

<div class="post-metadata">

**Author:** ![tushar20sharma](https://avatars.discourse-cdn.com/v4/letter/t/cdc98d/32.png) [@tushar20sharma](https://forums.ankiweb.net/u/tushar20sharma)\
**Post date:** [December 20, 2022, 7:35am UTC](https://forums.ankiweb.net/t/how-can-i-set-auto-zoom-into-masked-area-of-image-card-made-withimage-occlusion-enhanced/25497/3 "2022-12-20T07:35:37Z")

</div>

First of all Thanku @kleinerpirat for your reply

Actually i am pretty new to anki and doesn’t know about scripting also .

Can you be please kind to give steps where i have to add this script in my anki desktop. I am using latest version of anki .

Thanks again

---

<div class="post-metadata">

**Author:** ![kleinerpirat](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/kleinerpirat/32/19863_2.png) [@kleinerpirat](https://forums.ankiweb.net/u/kleinerpirat)\
**Post date:** [December 20, 2022, 7:13pm UTC](https://forums.ankiweb.net/t/how-can-i-set-auto-zoom-into-masked-area-of-image-card-made-withimage-occlusion-enhanced/25497/4 "2022-12-20T19:13:18Z")

</div>

Either select one of your IO notes in the browser or choose the notetype in the Add window. Then click on “Cards…”:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/anki2/original/2X/7/75bdde5196e0b4bf614e77ee108ee19655b8b50b.png)

Then add the JS wrapped in a `<script>` tag into the Front Template, like this:

```auto
<script>
  /** Auto-scroll for Image Occlusion Enhanced
  * @author Matthias Metelka <github.com/kleinerpirat>
  */
  (async function () {
     const img = document.querySelector("#io-overlay>img");
     const file = await fetch(img.src);
     const mask = new DOMParser()
         .parseFromString(await file.text(), "image/svg+xml")
         .querySelector("svg");

     mask.removeAttribute("height");
     mask.removeAttribute("width");
     mask.style.cssText = "position: absolute; top: 0; right: 0; bottom: 0; left: 0;";
     img.parentNode.insertBefore(mask, img);

     mask.querySelector("rect.qshape").scrollIntoView({
         block: "center",
         inline: "center",
     });
     mask.remove();
  })();
</script>
```

---

<div class="post-metadata">

**Author:** ![tushar20sharma](https://avatars.discourse-cdn.com/v4/letter/t/cdc98d/32.png) [@tushar20sharma](https://forums.ankiweb.net/u/tushar20sharma)\
**Post date:** [December 20, 2022, 10:03pm UTC](https://forums.ankiweb.net/t/how-can-i-set-auto-zoom-into-masked-area-of-image-card-made-withimage-occlusion-enhanced/25497/5 "2022-12-20T22:03:56Z")

</div>

thanks @kleinerpirat it is working fine on my desktop anki now.

is their any workaround or other solution to do same on my ankidroid ?

as because on ankkidroid it is not working

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex002/uploads/anki2/original/1X/8f1279ababc5879d54e4838989f606cfe55af8c7.jpeg) [@system](https://forums.ankiweb.net/u/system)\
**Post date:** [January 19, 2023, 10:04pm UTC](https://forums.ankiweb.net/t/how-can-i-set-auto-zoom-into-masked-area-of-image-card-made-withimage-occlusion-enhanced/25497/6 "2023-01-19T22:04:29Z")

</div>

Closed on January 19, 2023, 10:04pm UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
