skip to Main Content

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


  1. You are aware that toJSON function is in a fork project of the original right? So if you install psd using npm, you will get the original project which has no toJSON function.

    You should checkout the fork (won21kr) and either put it in your node_modules folder, or put it somewhere else and access the js file with a relative module path notation: require('./psd-fork/index.js').

    Login or Signup to reply.
  2. change psd.tree().descendants()[0]; to psd.tree().descendants()[0].export();

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search