# Adobe Xd API - Adding filter

**URL:** <https://forums.creativeclouddeveloper.com/t/adobe-xd-api-adding-filter/3258>\
**Category:** UXP Plugin API\
**Created:** [July 9, 2021, 12:12am UTC](https://forums.creativeclouddeveloper.com/t/adobe-xd-api-adding-filter/3258 "2021-07-09T00:12:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kartoon](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/kartoon/32/1524_2.png) [@kartoon](https://forums.creativeclouddeveloper.com/u/kartoon)\
**Post date:** [July 9, 2021, 12:12am UTC](https://forums.creativeclouddeveloper.com/t/adobe-xd-api-adding-filter/3258/1 "2021-07-09T00:12:26Z")

</div>

Dear Adobe XD Community,

Appreciate if you can help me with the following.

What we want to achieve:  
We have an image that the user has added to the design. We have applied a filter and want to fill the image with the modified pixels.

We are following the example in “[ImageFill · Adobe XD Plugin Reference](https://adobexdplatform.com/plugin-docs/reference/ImageFill.html)” but it does not work.  
Basically what we do is

1. changing it to base64
2. apply filter
3. fill the image with base64 again.

The error we receive is “Error: Panel plugin edits must be initiated from a supported UI event”.

It’s the part of our code:

```auto
let imageFile = await xhrBinary(url, src, type, node.width, node.height)
// Create ImageFill for this image
const ImageFill = require("scenegraph").ImageFill;
let fill = new ImageFill(imageFile);
selection.items = node
selection.items[0].fill = fill;

```

---

<div class="post-metadata">

**Author:** ![Velara](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/velara/32/1278_2.png) [@Velara](https://forums.creativeclouddeveloper.com/u/Velara)\
**Post date:** [July 9, 2021, 2:38am UTC](https://forums.creativeclouddeveloper.com/t/adobe-xd-api-adding-filter/3258/2 "2021-07-09T02:38:48Z")

</div>

You may need to wrap your code inside of an editDocument call.

- Panel UI [DOM](https://adobexdplatform.com/plugin-docs/GLOSSARY.html#dom) events – Most UI events in panels allow you to edit the document, but you must [initiate an edit operation _explicitly_](https://adobexdplatform.com/plugin-docs/reference/core/lifecycle.html#initiating-an-edit-operation-from-panel-ui).

[https://adobexdplatform.com/plugin-docs/reference/core/lifecycle.html#edit-operations](https://adobexdplatform.com/plugin-docs/reference/core/lifecycle.html#edit-operations)
