Automating and manipulating media is a fascination of mine, partly because I don’t understand the magic behind it and partly because the idea of turning one thing into another is fun and useful.  That latest media tool that has piqued my interest is a JavaScript tool called psd.js.

psd.js is a project that allows you to read PSD files, including:

  • Document structure and size
  • Layer/folder size + positioning, names, visibility, and opacity
  • Font data (via psd-enginedata)
    • Text area contents
    • Font names, sizes, and colors
  • Color mode and bit-depth
  • Vector mask data
  • Flattened image data
  • Layer comps

What the media converter and JavaScript lover in me found most awesome was one basic feature: converting a PSD to PNG with JavaScript!

var PSD = require('psd');
 
PSD.open('designs/homepage.psd').then(function (psd) {
  return psd.image.saveAsPng('homepage.png');
}).then(function () {
  console.log('Finished!');
});

That’s a nice, tidy API there and I love that it doesn’t require anything other than JavaScript (may other Node.js image libraries require ImageMagick on the machine).  Of course converting PSD to PNG is easy with ImageMagick too, but being able to use Nodej.s instead opens a whole host of opportunity!

The post Convert PSD to PNG with Node.js appeared first on David Walsh Blog.

Source: http://davidwalsh.name/feed