I encountered an issue while using the ag-psd library in Node.js to programmatically update text content in a PSD file. Despite successfully updating the text content in the PSD layer object, the image remains unchanged after saving the modified PSD file.
Here's the relevant code snippet:
import * as fs from 'fs';
import 'ag-psd/initialize-canvas.js';
import { readPsd, writePsdBuffer } from 'ag-psd';
const buffer = fs.readFileSync('UK DL FRONT.psd');
const psd = readPsd(buffer);
const kumonLayer = psd.children[4].children.find(layer => layer.name === 'KUMON');
if (kumonLayer) {
kumonLayer.text.text = 'MD. Asif';
console.log('Updated text content:', kumonLayer.text.text);
console.log('Updated layer:', kumonLayer.name);
const modifiedBuffer = writePsdBuffer(psd);
fs.writeFileSync('modified_UK_DL_FRONT.psd', modifiedBuffer);
console.log('Text for KUMON layer updated successfully.');
} else {
console.log('Layer with name "KUMON" not found.');
}
Expected behavior:
I expect that when I update the text content of the PSD layer object and save the modified PSD file, the image in the PSD file should also reflect the changes made to the text content.
Actual behavior:
After running the above code, the text content in the PSD layer object (kumonLayer.text.text) is updated successfully, but when I open the modified PSD file, the image remains unchanged. It seems like the changes made to the layer object are not reflected in the saved PSD file.
I encountered an issue while using the ag-psd library in Node.js to programmatically update text content in a PSD file. Despite successfully updating the text content in the PSD layer object, the image remains unchanged after saving the modified PSD file.
Here's the relevant code snippet:
Expected behavior:
I expect that when I update the text content of the PSD layer object and save the modified PSD file, the image in the PSD file should also reflect the changes made to the text content.
Actual behavior:
After running the above code, the text content in the PSD layer object (
kumonLayer.text.text
) is updated successfully, but when I open the modified PSD file, the image remains unchanged. It seems like the changes made to the layer object are not reflected in the saved PSD file.