meltingice / psd.js

A Photoshop PSD file parser for NodeJS and browsers
MIT License
2.73k stars 390 forks source link

In react, psd.js reports an error #192

Open walker188 opened 4 years ago

walker188 commented 4 years ago

My code: ` import PSD from 'psd.js/dist/psd.min'

PSD.fromURL("../public/pea.psd") .then((psd) => { console.log("psd", psd) }) .catch((err) => { console.log("err", err) }) `

But I have got an error, how can I solve it err Error: Invalid file signature detected. Got: <!DO. Expected 8BPS. at e.parse (psd.min.js:6) at a.parseHeader (psd.min.js:6) at a.parse (psd.min.js:6) at XMLHttpRequest.i.onload (psd.min.js:7)

the-marolie commented 3 years ago

@walker188 Were you able to resolve this?

HaiNV266 commented 2 years ago

I'm having same error. Can anyone help me, pls ?

rhythmone commented 2 years ago

Same here. And I also get this (depending on file trying to import) RangeError: Invalid typed array length: 26133563965440

tangpingping commented 1 year ago

try this, use Blob

document.getElementById('psd_file_upload').addEventListener('change', function (file) {   
    let url = file.target.files[0]
    let fr = new FileReader();
    fr.readAsDataURL(url);

    fr.onload = function () {
        console.log(fr.result)
        PSD.fromURL(fr.result).then((psd) => {
            console.log(psd);
        });
    }
})