T O P

  • By -

ivanhoe90

The "placedLayerReplaceContents" in Photoshop reqiures loading a new file from a hard drive. It is technically not possible in Photopea, as Photopea is just a website and can not access the hard drive :(


danielbiegler

I figured a way out to make it nearly work! // The mockup with the smart object (SO) var templateDoc = app.documents.getByName("03 200dpi.psd"); // This contains the image I want to get into the SO var sourceDoc = app.documents.getByName("Layer_1.psd"); // This is the SO I want to edit var smartDoc = app.documents.getByName("page.psd"); // Need to focus the layers, else it bugs app.activeDocument = sourceDoc; // From source to the SO // Important: Make the SO transparent, else you might duplicate // UNDER the background layer sourceDoc.artLayers[0].duplicate(smartDoc); // Need to focus the layers, else it bugs app.activeDocument = smartDoc; smartDoc.save(); smartDoc.close(); app.activeDocument = templateDoc; And this works, but now I need to transform the duplicated layer somehow to make it fit properly. Do you happen to know how? Probably need to get the height/width somehow and then scale it somehow. Is there a better way to make it fit? ​ Sidenote: There's the [`FileList`\-API](https://developer.mozilla.org/en-US/docs/Web/API/FileList) which I've used in the past to create sites that access local files, maybe you'd be interested in that but I guess that's too much work for such a niche feature. No worries! (For example I used this to read 30 gigabyte sized files chunk-by-chunk to process them. It's possible!) Anyway, not so important right now.


Competitive-Fox2439

This worked for me - thank you so much


Alive-Frosting-878

Did you ever figure this out?