Describe the bug
Using paste() to paste more than one image result in tha same image being printer over and over instead of the clipboard containing a different image
To Reproduce
Steps to reproduce the behavior:
select 2 different png images (raw_p, eng_p)
(required win32clipboard and Pillow)
Run this code
import photoshop.api as ps
from PIL import Image
from io import BytesIO
import win32clipboard
if eng_p != "":
send_to_clipboard(eng_img)
eng = doc.paste()
eng.name = "eng"
eng.allLocked = True
eng.visible = False
g1 = doc.layerSets.add()
g1.name = "Clean"
g2 = doc.layerSets.add()
g2.name = "Translation"
for layer in doc.layers:
if layer.name == "Background":
layer.remove()
**Expected behavior**
you will see that both: eng and row in the generated psd are the same image but if you open paint and simpli presst ctrl+v you will notice that the pasted image is different than the one in phosotop.
**Desktop (please complete the following information):**
- OS: Windows10
- Photoshop Version: Photoshop-2023
- Python Version: 3.11
**Additional context**
I don't wanna use tmp file to add images to a psd if I can move everything in memory
Describe the bug Using paste() to paste more than one image result in tha same image being printer over and over instead of the clipboard containing a different image
To Reproduce Steps to reproduce the behavior:
select 2 different png images (raw_p, eng_p) (required win32clipboard and Pillow)
Run this code
def send_to_clipboard(image: Image): output = BytesIO() image.convert('RGB').save(output, 'BMP') data = output.getvalue()[14:] output.close()
raw_p = r"path\to\1\img.png" eng_p = r"path\to\2\img.png"
raw_img = Image.open(raw_p) eng_img = Image.open(eng_p)
send_to_clipboard(raw_img) psapp = ps.Application() doc = psapp.documents.add(raw_img.width, raw_img.height, 72.0, "NewDoc") raw = doc.paste() raw.name = "raw" if eng_p != "" else "eng" raw.allLocked = True
if eng_p != "": send_to_clipboard(eng_img) eng = doc.paste() eng.name = "eng" eng.allLocked = True eng.visible = False
g1 = doc.layerSets.add() g1.name = "Clean"
g2 = doc.layerSets.add() g2.name = "Translation"
for layer in doc.layers: if layer.name == "Background": layer.remove()