Commit 860aea39 authored by Ryan LeFevre's avatar Ryan LeFevre

Merge branch 'master' into channel_images

parents c895ffd7 e63bf76d
language: node_js language: node_js
node_js: node_js:
# - "0.11" - "0.11"
- "0.10" - "0.10"
# - "0.8"
\ No newline at end of file
...@@ -9,7 +9,6 @@ task 'compile', 'Compile with browserify for the web', -> ...@@ -9,7 +9,6 @@ task 'compile', 'Compile with browserify for the web', ->
.transform('coffeeify') .transform('coffeeify')
.require('./shims/png.coffee', expose: './image_exports/png.coffee') .require('./shims/png.coffee', expose: './image_exports/png.coffee')
.require('./shims/init.coffee', expose: './psd/init.coffee') .require('./shims/init.coffee', expose: './psd/init.coffee')
.require('./shims/rgb.coffee', expose: './image_modes/rgb.coffee')
.require('./lib/psd.coffee', expose: 'psd') .require('./lib/psd.coffee', expose: 'psd')
.bundle (err, src) -> .bundle (err, src) ->
return console.log(err) if err? return console.log(err) if err?
......
...@@ -4,13 +4,11 @@ ...@@ -4,13 +4,11 @@
A general purpose PSD parser written in Coffeescript. Based off of [PSD.rb](https://github.com/layervault/psd.rb). A general purpose PSD parser written in Coffeescript. Based off of [PSD.rb](https://github.com/layervault/psd.rb).
Runs in both NodeJS and the browser (using browserify). There are still some pieces missing that are present in PSD.rb, such as layer comp filtering, a built-in renderer, and many layer info blocks. The eventual goal is full feature parity with PSD.rb. Runs in both NodeJS and the browser (using browserify). There are still some pieces missing that are present in PSD.rb, such as layer comp filtering, layer image exporting, a built-in renderer, and many layer info blocks. The eventual goal is full feature parity with PSD.rb.
## Installation ## Installation
Before installing from npm, you must install libpng, which is available on all popular package management systems. On OSX with homebrew, you can do `brew install libpng`. The install success for node-png is currently hit or miss, so alternate image packages are currently under consideration. PSD.js has no native dependencies. Simply add `psd` to your package.json or run `npm install psd`.
Once your system is ready, simply add to your package.json dependencies or run `npm install psd`.
## Basic Usage ## Basic Usage
......
This diff is collapsed.
fs = require 'fs' fs = require 'fs'
{Png} = require 'png' {PNG} = require 'pngjs'
RSVP = require 'rsvp' RSVP = require 'rsvp'
module.exports = module.exports =
toPng: -> toPng: ->
new RSVP.Promise (resolve, reject) => new RSVP.Promise (resolve, reject) =>
png = new Png(new Buffer(@pixelData), @width(), @height(), 'rgba') png = new PNG(filterType: 4, width: @width(), height: @height())
png.encode(resolve)
png.data = @pixelData
resolve(png)
saveAsPng: (output) -> saveAsPng: (output) ->
new RSVP.Promise (resolve, reject) => new RSVP.Promise (resolve, reject) =>
@toPng() @toPng().then (image) ->
.then (image) -> image
fs.writeFile output, image.toString('binary'), 'binary', resolve .pack()
.pipe(fs.createWriteStream(output))
.on 'finish', resolve
...@@ -5,13 +5,14 @@ module.exports = ...@@ -5,13 +5,14 @@ module.exports =
.filter (ch) -> ch >= -1 .filter (ch) -> ch >= -1
for i in [0...@numPixels] for i in [0...@numPixels]
r = g = b = a = 0 r = g = b = 0
a = 255
for chan, index in rgbChannels for chan, index in rgbChannels
val = @channelData[i + (@channelLength * index)] val = @channelData[i + (@channelLength * index)]
switch chan switch chan
when -1 then a = 255 - val when -1 then a = val
when 0 then r = val when 0 then r = val
when 1 then g = val when 1 then g = val
when 2 then b = val when 2 then b = val
......
{ {
"name": "psd", "name": "psd",
"description": "A general purpose Photoshop file parser.", "description": "A general purpose Photoshop file parser.",
"version": "1.0.1", "version": "1.0.2",
"main": "./index.js", "main": "./index.js",
"keywords": ["psd", "parser", "photoshop", "adobe", "reader"], "keywords": ["psd", "parser", "photoshop", "adobe", "reader"],
"repository": { "repository": {
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
"coffee-script": "~ 1.7.1", "coffee-script": "~ 1.7.1",
"jspack": "~ 0.0.3", "jspack": "~ 0.0.3",
"coffeescript-module": "~ 0.2.1", "coffeescript-module": "~ 0.2.1",
"png": "~ 3.0.3", "pngjs": "~ 0.4.0",
"rsvp": "~ 3.0.6", "rsvp": "~ 3.0.6",
"lodash": "~ 2.4" "lodash": "~ 2.4"
}, },
......
module.exports =
combineRgbChannel: ->
rgbChannels = @channelsInfo
.map (ch) -> ch.id
.filter (ch) -> ch >= -1
for i in [0...@numPixels]
r = g = b = 0
a = 255
for chan, index in rgbChannels
val = @channelData[i + (@channelLength * index)]
switch chan
when -1 then a = val
when 0 then r = val
when 1 then g = val
when 2 then b = val
@pixelData.push r, g, b, a
\ No newline at end of file
test/fixtures/out.png

12.5 KB | W: | H:

test/fixtures/out.png

16.7 KB | W: | H:

test/fixtures/out.png
test/fixtures/out.png
test/fixtures/out.png
test/fixtures/out.png
  • 2-up
  • Swipe
  • Onion skin
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment