You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I created this PSD file.psd.zip from this PNG file.png.zip, using https://github.com/dlemstra/magick-wasm . That magick library (for the browser) works on converting PNG to JPG/etc., and I saved the bytes output from the selected browser file to a .psd file on my computer, and that is the contents of file.psd.zip. That psd seems to render on my Mac (and with CMD+space it shows large):
That png itself was generated from another png (I'm playing with magick-wasm), if that matters. But it renders as a PSD locally if I say the bytes to a .psd file, but I get this error in Psd.parse(arrayBuffer):
my-app/node_modules/.pnpm/@[email protected]/node_modules/@webtoon/psd/dist/index.js:397
throw new Le();
^
Le
at wt (my-app/node_modules/.pnpm/@[email protected]/node_modules/@webtoon/psd/dist/index.js:397:11)
at fn (my-app/node_modules/.pnpm/@[email protected]/node_modules/@webtoon/psd/dist/index.js:1188:76)
at Rn (my-app/node_modules/.pnpm/@[email protected]/node_modules/@webtoon/psd/dist/index.js:1490:13)
at Function.parse (my-app/node_modules/.pnpm/@[email protected]/node_modules/@webtoon/psd/dist/index.js:1982:15)
at <anonymous> (my-app/tmp/psd.ts:162482:21)
at Object.<anonymous> (my-app/tmp/psd.ts:162490:4)
at Module._compile (node:internal/modules/cjs/loader:1376:14)
at Object.F (my-app/node_modules/.pnpm/@[email protected]/node_modules/@esbuild-kit/cjs-loader/dist/index.js:1:941)
at Module.load (node:internal/modules/cjs/loader:1207:32)
at Module._load (node:internal/modules/cjs/loader:1023:12)
Node.js v20.10.0
This is occurring whether or not I'm calling Psd.parse in Node.js or the browser. So it fails to parse the PSD, and so I can't render the PSD in the browser.
Any ideas what is wrong with this PNG, or why this isn't parsing?
I get the same error when trying to parse a JPEG as well, so not sure.
My messy code, with the PSD functionality temp hacked in for now:
useEffect(()=>{if(!files?.length){return}constfile=files[0]setInput(file)// https://www.npmjs.com/package/wasm-imagemagickfile.arrayBuffer().then(asyncdata=>{constir=newFileReader()ir.onloadend=()=>{setInputString(ir.resultasstring)}ir.readAsDataURL(file)if(data.byteLength<=bytes('16mb')){if(outputFormat==='psd'){constcanvasElement=canvasRef.currentif(canvasElement){try{console.log(bufferToString(awaitfile.arrayBuffer()))functionbufferToString(buf: ArrayBuffer){varview=newUint8Array(buf)vararray: Array<string>=[]Array.prototype.forEach.call(view,item=>{array.push('0x'+(itemasnumber).toString(16).padStart(2,'0'),)})return`[ ${array.join(',\n ')} ]`}constpsdFile=Psd.parse(awaitfile.arrayBuffer())constcontext=canvasElement.getContext('2d')constcompositeBuffer=awaitpsdFile.composite()constimageData=newImageData(compositeBufferasUint8ClampedArray,psdFile.widthasnumber,psdFile.heightasnumber,)setShowCanvas(true)canvasElement.width=psdFile.widthcanvasElement.height=psdFile.heightcontext?.putImageData(imageData,0,0)}catch(e){console.log(e)}}}else{readWithImageMagickCallback(newUint8Array(data),(err,image)=>{if(err){console.log(err)returnsetInputError(err.messageasstring)}elseif(image){writeWithImageMagick(image,outputFormat).then(out=>{setInputError(undefined)constpath=file.name.split('.')if(path.length>1){path.pop()}constblob=newBlob([out])setOutput(blob)setOutputFileName(`${path.join('.')}.${outputFormat.toLowerCase()}`,)// downloadBlob(// blob,// `${path.join('.')}.${outputFormat.toLowerCase()}`,// )constor=newFileReader()or.onloadend=()=>{setOutputString(or.resultasstring)}or.readAsDataURL(blob)}).catch(error=>{setInputError(error.messageasstring)})}},)}}else{setInputError(`File should be less than 16mb so it doesn't crash the browser.`,)}})},[files,outputFormat,canvasRef])
The text was updated successfully, but these errors were encountered:
Not sure why the code is not getting sourcemapped to TypeScript (unminified), I see the //#sourceMappingURL=index.js.map in the dist/index.js file, is this fixable? I'll open another issue.
I created this PSD file.psd.zip from this PNG file.png.zip, using https://github.com/dlemstra/magick-wasm . That magick library (for the browser) works on converting PNG to JPG/etc., and I saved the bytes output from the selected browser file to a
.psd
file on my computer, and that is the contents offile.psd.zip
. That psd seems to render on my Mac (and with CMD+space it shows large):That png itself was generated from another png (I'm playing with magick-wasm), if that matters. But it renders as a PSD locally if I say the bytes to a
.psd
file, but I get this error inPsd.parse(arrayBuffer)
:This is occurring whether or not I'm calling
Psd.parse
in Node.js or the browser. So it fails to parse the PSD, and so I can't render the PSD in the browser.Any ideas what is wrong with this PNG, or why this isn't parsing?
I get the same error when trying to parse a JPEG as well, so not sure.
My messy code, with the PSD functionality temp hacked in for now:
The text was updated successfully, but these errors were encountered: