when I wanted to have the same image 2 time in 2 differents variables so i can modify one while keeping the other as a reference. I used to to it like that:
im1 = Image.open(imagepath)
im2 = im1
and i always got issues while doing that because, if i modify one image, the other will also be modified. You can try it yourself if you want:
from PIL import Image
im1 = Image.open(r"D:\python\pixelartor\pixelartor_v3.1\pkg\trezor\trezor_0007.png")
im1.show()
im2 = im1
for x in range(100):
for y in range(100):
im2.putpixel((x,y),(255,0,0))
im1.show()
as you can see in the above script, i show im1, then i modify im2 and show im1 again but the first im1 and the second aren't the same but i never asked pillow to modify im1:
I think there is a much clever way to copy PIL.Images but i don't find anything on the web. And please don't tell me to open the image 2 times because it won't work in my case. I hope someone will hep me because i faced this issue 2 weeks ago, so i abandonned my project and i restarted the same project from scratch this week and the same problem happened, but this time, i tried to understand what was happening.