Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let getBase64TypeFromPhotoshopFilePath = (filepath, options) => {
if (!fs.existsSync(filepath)) return null
initializeCanvas((width, height) => {
let canvas = document.createElement('canvas');
canvas.width = width;
canvas.height = height;
return canvas;
});
let psd
try {
const buffer = fs.readFileSync(filepath)
psd = readPsd(buffer)
} catch(exception) {
console.error(exception)
return null
}
if(!psd || !psd.children) {
return;
}
let mainCanvas = options.mainCanvas
if(!mainCanvas) {
mainCanvas = document.createElement('canvas')
mainCanvas.width = psd.width
mainCanvas.height = psd.height
}
let mainContext = mainCanvas.getContext('2d');
return canvas
}
)
let importable = [
'reference',
'fill',
'tone',
'pencil',
'ink',
'notes'
]
let psd
try {
psd = readPsd(buffer)
} catch (err) {
console.error(err)
}
if (!psd) {
console.warn('PSD is invalid', psd)
return
}
console.log('got psd', psd)
let numChannelValues = (1 << psd.bitsPerChannel) - 1
let canvases = { }
const canvasNameForLayer = name => {