Open 826327700 opened 4 months ago
You can save psd.canvas
, in browser it's regular HTMLCanvasElement ( https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement ) and in node it's node-canvas canvas object ( https://github.com/Automattic/node-canvas?tab=readme-ov-file#non-standard-apis )
The PSD document is not guaranteed to have composite image saved in it, most documents have it though.
您可以保存
psd.canvas
,在浏览器中它是一个常规的 HTMLCanvasElement(https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement),在节点中它是一个 node-canvas 画布对象(https://github.com/Automattic/node-canvas?tab=readme-ov-file#non-standard-apis)PSD文档不保证其中保存有复合图像,但其它文档都有。
I have tried using the following code but the psd.canvas is empty
import { readPsd } from 'ag-psd';
import 'ag-psd/initialize-canvas';
let buf=fs.readFileSync('xxxx.psd');
const psd = readPsd(buf.buffer,{ skipLayerImageData: true, skipCompositeImageData: true, skipThumbnail: true });
console.log("======",psd.canvas);//-->undefined
skipCompositeImageData: true
option skips reading psd.canvas
fields, you need to remove it.
I didn't get clear instructions in the documentation how to export psd to image, hope someone can tell me。