-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to replace an image within a Smart Object? #173
Comments
See section on smart objects: https://github.com/Agamnentzar/ag-psd/blob/master/README_PSD.md#smart-objects Be aware that updating smart objects has the same issues that updating text or vector layers, PSD file keep s prerendered version of the layer and you have to update that bitmap yourself, the library will not do that for you. |
and how can i update it? |
i saw that but i cant figure out how can i insert a PNG image into that code |
You need to add the file to psd.linkedFiles = [
{
"id": "20953ddb-9391-11ec-b4f1-c15674f50bc4",
"name": "cat.png"
"data": fileContentsAsUint8Array,
}
]; and then refer to that file by the layer.placedLayer = {
"id": "20953ddb-9391-11ec-b4f1-c15674f50bc4", // id that matches linkedFiles ID
"placed": "20953dda-9391-11ec-b4f1-c15674f50bc4", // unique id for this object
"type": "raster", // one of the 'unknown', 'vector', 'raster' or 'image stack'
"transform": [ // x, y of 4 corners of the transform box
29,
28,
83,
28,
83,
82,
29,
82
],
"width": 32, // width and height of the target image
"height": 32,
"resolution": {
"value": 299.99940490722656,
"units": "Density"
}
}; You also need to update |
Id can be whatever i want? |
I don't know, it seems photoshop puts GUIDS there, so I'd advise to use something in the same format, in case Photoshop expects it to be like that. |
A friend of mine helped me with the code but when i debugged it, it didnt worked, what maybe wrong here?
|
|
new code ` const newImageBuffer = fs.readFileSync('Profile.png');
` and this is the new error
|
are you sure |
thanks, that was the problem, but now its having the same error of the text layer, can something be done to solve this? |
what method can i use to update |
You just assign it a new canvas, node-canvas has the same api as regular javascript canvas: https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API |
`const newImageBuffer = fs.readFileSync('Profile.png');
` |
do you have any code doing so? Or how can i implement what you just said into my code? |
hi @Agamnentzar , can you explain how to draw png to layer canvas with transform please ? |
@DEV-Devound You need to assign new canvas to
|
@houxiaohou |
@DEV-Devound did you figure it out? |
I think I have done it. Welcome to contact me. - [email protected] |
like this:

i want to replace the image within it so that photoshop does its own filters by itself. I didnt found any reference on the documentation or maybe im too lackadaisical
The text was updated successfully, but these errors were encountered: