npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

o2team-psd-parser

v0.4.3

Published

Parse psd and output a json obj

Downloads

5

Readme

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 = await 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~~