Im using https://github.com/meltingice/psd.js to parse a PSD file in node,
I see that toJSON() can be used, https://github.com/won21kr/psd.js-1
but when I try to use on a simple hello world after installing the module,
npm install psd
toJSON() gives me error:
info = psd.toJSON();
^ TypeError: Object # has no method ‘toJSON’
normal log works fine,
var PSD = require('psd');
var psd = PSD.fromFile("AntoineVeglas_Filter_BW.psd");
psd.parse();
node = psd.tree().descendants()[0];
console.log(node);
info = psd.toJSON();
how to parse to valid json my psd tree object? cheers
2
Answers
You are aware that
toJSON
function is in a fork project of the original right? So if you installpsd
usingnpm
, you will get the original project which has notoJSON
function.You should checkout the fork (
won21kr
) and either put it in yournode_modules
folder, or put it somewhere else and access thejs
file with a relative module path notation:require('./psd-fork/index.js')
.change psd.tree().descendants()[0]; to psd.tree().descendants()[0].export();