GithubHelp home page GithubHelp logo

bellyabc123 / psd-reader Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lavrovd/psd-reader

0.0 2.0 0.0 1.64 MB

Fast and light Photoshop® PSD file parser for JavaScript

License: MIT License

CSS 2.23% HTML 22.50% JavaScript 75.27%

psd-reader's Introduction

psd-reader

Display Adobe® Photoshop® PSD files directly in the web browser.

  • Use PSD files as an image source for canvas.
  • Convert PSD to PNG or JPEG directly in the browser.
  • Create slide-shows with support for PSD files.

demo snapshot

Features

  • Fast and lightweight
  • Asynchronous and segment-based decoding (no UI-blocking)
  • No dependencies
  • Reads all supported formats (Greyscale, Bitmap, Indexed, RGB, CMYK, DuoTone, Multi-channel and Lab)
  • Reads all color depths (1/8/16/32 bits)
  • Handles alpha channel, and transparency for indexed mode
  • De-matte (matte removal) processing of images with alpha-channel (eliminates "halo" problems)
  • Supports RLE compressed and uncompressed image data
  • By default, converts all formats to RGBA so it can be used directly with canvas
  • Canvas helper method with optional scaling and high-quality down-sampling
  • Optional gamma correction
  • By default, auto-corrects display gamma for 32-bit color mode
  • Access to the original channel bitmaps (decompressed if needed)
  • Access to raw meta and header data
  • Access to resource chunks (incl. ID locator method)
  • Passive load mode allowing parsing to be invoked manually later
  • Validates and performs error checks
  • Works in all major browsers (Firefox, Chrome, IE, Opera, Safari).
  • For client-side use
  • An original parser implementation built from scratch.
  • Full documentation (see docs/ folder or online docs)

Demos

Demos demonstrating psd-reader.

Note that PSD files can be relative large in size so please be patient when downloading the test images for the acid-test demo.

Acid-test - various color modes, formats and depths

Built-in gamma correction

Drop in your own PSD files

Install

Install psd-reader in various ways:

Documentation

The project is documented and is available as html in the docs folder

The documentation can be viewed online

Tutorials and general information is included in the docs.

Usage

Create a new instance, pass in an URL (or an array buffer), and a callback:

var psd = new PsdReader({url: "path/to.psd", onLoad: myCallback});

In your callback you can access the RGBA data:

function myCallback(e) {
    var bitmap = this.rgba;
}

To get a canvas version of the data:

function myCallback(e) {
    var canvas = this.toCanvas();
    ...
}

An already existing ArrayBuffer can be used instead of an URL:

var psd = new PsdReader({buffer: psdArrayBuffer, onLoad: myCallback});

There is additional access to the original channel bitmap data in it´s native format (8-bit, 16-bit etc.). The header information can be accessed through the info object:

var width     = psd.info.width;
var height    = psd.info.height;
var depth     = psd.info.depth;
var layers    = psd.info.chunks[3];		// the layers area

var channel0  = psd.bitmaps[0];	        // in native format (but uncompressed)
...

A method to locate resources is included:

var icc = psd.findResource(1039);       // find resource with resource ID

Requirements

A browser with support for HTML5 Canvas and typed arrays.

There are no dependencies.

Limitations

These are generally non-problematic, but something to have in mind:

  • Does not intend to parse individual layers (we will publish something for this later)
  • The PSD must be saved in (the typical) compatibility mode (see tutorial section in docs for details)
  • ICC profiles are not parsed/applied

Issues

See the issue tracker for details.

Please do report issues if you find any.

License

Released under MIT license. You may use this class in both commercial and non-commercial projects provided that full header (minified and developer versions) is included.

© 2015 Epistmex

Epistemex

psd-reader's People

Watchers

AAA avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.