Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

psd-parser

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

psd-parser

Parse psd and output a json obj

  • 0.1.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

PSD Parser

造个轮子

参考文档

官方psd文档,部分有错 Adobe Photoshop File Formats Specification

翻译文档(不完整) Adobe Photoshop File Formats Specification

其他的PSD解析

coffee版 psd.js

ruby版 psd.rb

c版 psdump

因为 ruby 版与 c 版对于前端来讲不好直接拿来用呐,coffee版输出的对象很庞大,同时运行时还要先编译一下,于是 生命不息,折腾不止 ,有了这个版本;

安装

npm install psd-parser

简单使用


	var PSD = require('psd-parser');
	var psd = PSD.parse('./test.psd');
	console.log(psd)
	psd.getDescendants() //扁平化的图层数组
	psd.getTree() //树型结构的图层数组,与psd中结构相符
    console.log(psd._psd_) //解析psd后的原始对象
    
    //psd缩略图的输出,只支持png输出
    psd.saveAsPng('test.png') //目前要注意目录是否存在
    //某个图层的png输出
    psd.getDescendants()[0].saveAsPng('layer.png')

现在可以获取文本图层中的文字与细节


    var PSD = require('../index');
    var psd = PSD.parse('./example/test.psd');

    console.log(psd.getDescendants()[0].get('text')); //文本图层中的文字
    console.log(psd.getDescendants()[0].get('wordSnippets')); //文本图层中的文字细节,以数组形式展现

TODO

  • 图层的树型输出
  • 文字图层处理
  • 挂一些get方法上去
  • saveAsPng 路径不存在时的错误
  • 发布到npm

Keywords

FAQs

Package last updated on 29 Jul 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc