# "copy pasting" without using the actual clipboard

**URL:** <https://forums.creativeclouddeveloper.com/t/copy-pasting-without-using-the-actual-clipboard/6474>\
**Category:** UXP Plugin API\
**Created:** [July 6, 2023, 6:17am UTC](https://forums.creativeclouddeveloper.com/t/copy-pasting-without-using-the-actual-clipboard/6474 "2023-07-06T06:17:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tais993](https://avatars.discourse-cdn.com/v4/letter/t/d78d45/32.png) [@Tais993](https://forums.creativeclouddeveloper.com/u/Tais993)\
**Post date:** [July 6, 2023, 6:17am UTC](https://forums.creativeclouddeveloper.com/t/copy-pasting-without-using-the-actual-clipboard/6474/1 "2023-07-06T06:17:26Z")

</div>

Heya,

I need to copy paste my selection into another document, but I’m trying to not use the clipboard.

So I found the imaging API, using getSelection I could “copy” the image data.  
Using putPixels I could then insert the selection back into a layer, I thought.  
But I keep having an error:  
“the target colourspace does not match the source data. A colour profile must be specified for the source data.”, so I tried setting the colour profile for the source (the ImageData received by getSelection), but that was readOnly, so didn’t work.

I thought, maybe use getPixels, but that wouldn’t make much sense in my eyes since I’d have to get the sourceBounds using getSelection then.

Another way could be to duplicate the selection into another document, I couldn’t get this working as Layer#duplicate duplicates the whole layer, and I couldn’t find something to remove an selection (I could selection invert → delete then)

I’m probably overthinking this or missing something, help is greatly appreciated!

---

<div class="post-metadata">

**Author:** ![Timothy\_Bennett](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/timothy_bennett/32/1251_2.png) [@Timothy\_Bennett](https://forums.creativeclouddeveloper.com/u/Timothy_Bennett)\
**Post date:** [July 6, 2023, 7:03am UTC](https://forums.creativeclouddeveloper.com/t/copy-pasting-without-using-the-actual-clipboard/6474/2 "2023-07-06T07:03:33Z")

</div>

How about copying selection to a new layer and then duplicating that into a new document?

---

<div class="post-metadata">

**Author:** ![Tais993](https://avatars.discourse-cdn.com/v4/letter/t/d78d45/32.png) [@Tais993](https://forums.creativeclouddeveloper.com/u/Tais993)\
**Post date:** [July 6, 2023, 7:31am UTC](https://forums.creativeclouddeveloper.com/t/copy-pasting-without-using-the-actual-clipboard/6474/3 "2023-07-06T07:31:12Z")

</div>

Heya Timothy,  
You mean using putPixels into a layer in the original’s document? And then using Layer#duplicate?  
I can try!

For context, I’m writing a script which creates images in a certain format (and sometimes with removed background), this script worst case has do 100 images, so I’m trying to not use the users clipboard so they can focus on something else while the script does its thing. (so many images takes couple minutes)

Performance improvements are something for the future, most important is a working script that doesn’t interfere anyone atm.

---

<div class="post-metadata">

**Author:** ![Timothy\_Bennett](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/timothy_bennett/32/1251_2.png) [@Timothy\_Bennett](https://forums.creativeclouddeveloper.com/u/Timothy_Bennett)\
**Post date:** [July 6, 2023, 8:05am UTC](https://forums.creativeclouddeveloper.com/t/copy-pasting-without-using-the-actual-clipboard/6474/4 "2023-07-06T08:05:19Z")

</div>

Nah, I mean New Layer via Copy from the Layers drop-down menu - CTRL + J.  
It copies the active layer (or selection) into a new layer in the existing document.  
Then you duplicate the new layer into a new document.  
No clipboard or image API.

---

<div class="post-metadata">

**Author:** ![Tais993](https://avatars.discourse-cdn.com/v4/letter/t/d78d45/32.png) [@Tais993](https://forums.creativeclouddeveloper.com/u/Tais993)\
**Post date:** [July 6, 2023, 8:55am UTC](https://forums.creativeclouddeveloper.com/t/copy-pasting-without-using-the-actual-clipboard/6474/5 "2023-07-06T08:55:23Z")

</div>

That works! Thanks sincerely for the help.
