How to use the ag-psd.readPsd function in ag-psd

To help you get started, we’ve selected a few ag-psd examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wonderunit / storyboarder / src / js / files / file-helper.js View on Github external
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');
github wonderunit / storyboarder / src / js / importers / psd.js View on Github external
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 => {

ag-psd

Library for reading and writing PSD files

MIT
Latest version published 10 days ago

Package Health Score

68 / 100
Full package analysis