Skip to content
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

psd.tree().export() getting stuck #90

Closed
benpptung opened this issue May 10, 2017 · 2 comments
Closed

psd.tree().export() getting stuck #90

benpptung opened this issue May 10, 2017 · 2 comments

Comments

@benpptung
Copy link

benpptung commented May 10, 2017

Hi, I am trying to use psd to replace imagemagick's identify() for psd file. Thank you for this excellent project!! I found it is much faster than imagemagick.identify().

However, when I tested it with some fake psd files, it seems the psd.js will be getting stuck.
Following please find how to reproduce the problem.

I am wondering if we can add some defensive codes to avoid export() getting stuck?
Thank you :)

'use strict';

const request = require('request');
const PSD = require('psd');
const Async = require('util-asyncflow');

var flow = new Async();
var fakefile = 'https://s3.amazonaws.com/tacolbiz/misc/car-photoshop-iff.iff';

flow.task(next=> {

  let s = request(fakefile);
  let buff = [];

  s.on('data', buf=> buff.push(buf))
    .on('end', _=> {
      buff = Buffer.concat(buff);
      next(null, buff);
    })
    .on('error', err=> next(err));

});

flow.wait(buff=> {

  let psd = new PSD(buff);
  psd.parse();

  let tree = psd.tree();

  console.log('will export() tree');

  tree = tree.export(); // getting stuck here.

  console.log('never see this');
});

flow.run(err=> console.error(err));
@fabulousduck
Copy link
Collaborator

fabulousduck commented Jul 11, 2017

Currently we do not check the signature of the file (which should be 8BPS for PSD files) even tho we have it stored (https://github.com/meltingice/psd.js/blob/master/lib/psd/header.coffee#L32).

I assume this will be fixed in the rewrite @meltingice ? But as that is not finished yet, i will see about making a PR that does the check.

With this check, it will fail on PSD.open(path/to/psd) as the signature of the file does not match.

@fabulousduck
Copy link
Collaborator

Pr for this has been merged and the issue resolved. closing this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants