📜 ⬆️ ⬇️

Parser PSD files on CoffeeScript


The author of the script psd.js is Ryan Lefevre. The script, as you already guessed, is able to open photoshop documents, both in the browser and on the Node.js side.

Demonstration of opportunities (early beta, do not be surprised that some files will not open. On the github project page, many people complain about this).

Example of displaying information on Node.js:
{PSD} = require 'psd.js' psd = PSD.fromFile './path/to/file.psd' psd.parse() for layer in psd.layerMask.layers console.log "Layer: #{layer.name}" console.log "Size: width=#{layer.cols}, height=#{layer.rows}" console.log "Position: top=#{layer.top}, left=#{layer.left}" 


')
The script analyzes and draws psd files. As long as its capabilities are not great, it can show the actual size of the images, color modes, information about the images included in the file, information about the layers, etc. Psd.js itself is written in CoffeeScript and can now be used by you to pull out the header, resources, layer structure, masks, and more from the file. Although the project has just appeared in public, I think, given the cost of adobe products and platform dependency (the photoshop in wine is pretty buggy), the script will find its fans, and maybe someone will help the author with the development;) The repository is on github .

The ultimate goal of the project is to implement a full-fledged photoshop in the browser, with the use of various effects of layers, filters and other difficult things to implement. For now, this is just a parser to get information about the structure of the PSD, but you can be sure that support for turning on / off layers will soon appear, and much later, editing directly in the browser. As the author himself writes, the script is partially ported with pypsd and psdparse.

The output of the available information from the demo looks like this:

Source: https://habr.com/ru/post/137379/


All Articles