# How to make a copy of image and change its attributes

**URL:** <https://discourse.psychopy.org/t/how-to-make-a-copy-of-image-and-change-its-attributes/28018>\
**Category:** Coding\
**Created:** [March 15, 2022, 8:58pm UTC](https://discourse.psychopy.org/t/how-to-make-a-copy-of-image-and-change-its-attributes/28018 "2022-03-15T20:58:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bill\_Liang](https://avatars.discourse-cdn.com/v4/letter/b/7bcc69/32.png) [@Bill\_Liang](https://discourse.psychopy.org/u/Bill_Liang)\
**Post date:** [March 15, 2022, 8:58pm UTC](https://discourse.psychopy.org/t/how-to-make-a-copy-of-image-and-change-its-attributes/28018/1 "2022-03-15T20:58:58Z")

</div>

**OS** : Win10  
**PsychoPy version** : v2022.1.1  
**Standard Standalone? (y/n)** : Yes

Hi all, I am trying to make an experiment where there are several images on the screen, and once participants click on one of the images, a copy of that image will appear in another area. (Imagine you are shopping online, and once you click on one product, that product gets into your cart). The problem I am running into is copying the imageStim and changing the position.  
’  
I understand that I can’t just use the ‘=’ operator and need to use the copy module. This is what I write:  
(let’s say I click on image1):

```auto
import copy
newImage = copy.copy(image1)
newImage.pos = (-0.2, -0.2)
image1.pos #([0.15, 0.33])
newImage.pos #([-0.2, -0.2])

```

I checked imag1.pos and newImage.pos, they have different numbers. But when I draw them, they are in the same position on the screen.

I am not familiar with python so I don’t understand what the problem is. I;ve tried using copy.deepcopy, but there is an error saying that “ctypes objects containing pointers cannot be pickled” .

Any suggestions on how I should make a copy of the image or how to fix the copy.copy issue? Thank you very much!

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [March 16, 2022, 12:31pm UTC](https://discourse.psychopy.org/t/how-to-make-a-copy-of-image-and-change-its-attributes/28018/2 "2022-03-16T12:31:25Z")

</div>

I’ve not heard of the copy module, but couldn’t you create a newImage as you would a normal image and then set newImage.setImage(image1.image) or similar?

---

<div class="post-metadata">

**Author:** ![Bill\_Liang](https://avatars.discourse-cdn.com/v4/letter/b/7bcc69/32.png) [@Bill\_Liang](https://discourse.psychopy.org/u/Bill_Liang)\
**Post date:** [March 16, 2022, 12:57pm UTC](https://discourse.psychopy.org/t/how-to-make-a-copy-of-image-and-change-its-attributes/28018/3 "2022-03-16T12:57:02Z")

</div>

Thank you for replying! I find a solution in the dragAndDrop demo by making a function to basically do what you say, creating a newImage.

I know about the copy module from this post.[https://discourse.psychopy.org/t/display-multiple-images-simultaneously/15967/9](https://discourse.psychopy.org/t/display-multiple-images-simultaneously/15967/9)
