Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
psd.js
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
regiostart
psd.js
Commits
b4361e14
Commit
b4361e14
authored
Nov 08, 2014
by
Ryan LeFevre
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'channel_images'
parents
8be456c8
539ca415
Changes
15
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
5549 additions
and
283 deletions
+5549
-283
LICENSE.txt
LICENSE.txt
+21
-0
psd.js
dist/psd.js
+5406
-275
export_layers.js
examples/node/export_layers.js
+17
-0
channel_image.coffee
lib/psd/channel_image.coffee
+66
-0
image.coffee
lib/psd/image.coffee
+1
-1
image_format.coffee
lib/psd/image_format.coffee
+3
-1
layer_raw.coffee
lib/psd/image_formats/layer_raw.coffee
+6
-0
layer_rle.coffee
lib/psd/image_formats/layer_rle.coffee
+7
-0
layer.coffee
lib/psd/layer.coffee
+2
-2
channel_image.coffee
lib/psd/layer/channel_image.coffee
+10
-0
layer_mask.coffee
lib/psd/layer_mask.coffee
+3
-1
node.coffee
lib/psd/node.coffee
+2
-1
build_preview.coffee
lib/psd/nodes/build_preview.coffee
+3
-0
group.coffee
lib/psd/nodes/group.coffee
+1
-1
layer.coffee
lib/psd/nodes/layer.coffee
+1
-1
No files found.
LICENSE.txt
0 → 100644
View file @
b4361e14
The MIT License (MIT)
Copyright (c) 2014 Ryan LeFevre
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
dist/psd.js
View file @
b4361e14
This diff is collapsed.
Click to expand it.
examples/node/export_layers.js
0 → 100644
View file @
b4361e14
var
PSD
=
require
(
'../../'
);
var
file
=
process
.
argv
[
2
]
||
'./examples/images/example.psd'
;
var
start
=
new
Date
();
PSD
.
open
(
file
).
then
(
function
(
psd
)
{
psd
.
tree
().
descendants
().
forEach
(
function
(
node
)
{
if
(
node
.
isGroup
())
return
true
;
node
.
saveAsPng
(
"./output/"
+
node
.
name
+
".png"
).
catch
(
function
(
err
)
{
console
.
log
(
err
.
stack
);
});
});
}).
then
(
function
()
{
console
.
log
(
"Finished in "
+
((
new
Date
())
-
start
)
+
"ms"
);
}).
catch
(
function
(
err
)
{
console
.
log
(
err
.
stack
);
});
lib/psd/channel_image.coffee
0 → 100644
View file @
b4361e14
_
=
require
'lodash'
Image
=
require
'./image.coffee'
ImageFormat
=
require
'./image_format.coffee'
module
.
exports
=
class
ChannelImage
extends
Image
@
includes
ImageFormat
.
LayerRAW
@
includes
ImageFormat
.
LayerRLE
constructor
:
(
file
,
header
,
@
layer
)
->
@
_width
=
@
layer
.
width
@
_height
=
@
layer
.
height
super
(
file
,
header
)
@
channelsInfo
=
@
layer
.
channelsInfo
@
hasMask
=
_
.
any
@
channelsInfo
,
(
c
)
->
c
.
id
<
-
1
@
opacity
=
@
layer
.
opacity
/
255.0
@
maskData
=
[]
skip
:
->
for
chan
in
@
channelsInfo
@
file
.
seek
chan
.
length
,
true
width
:
->
@
_width
height
:
->
@
_height
channels
:
->
@
layer
.
channels
parse
:
->
@
chanPos
=
0
for
chan
in
@
channelsInfo
if
chan
.
length
<=
0
@
parseCompression
()
continue
@
chan
=
chan
if
chan
.
id
<
-
1
@
_width
=
@
layer
.
mask
.
width
@
_height
=
@
layer
.
mask
.
height
else
@
_width
=
@
layer
.
width
@
_height
=
@
layer
.
height
@
length
=
@
_width
*
@
_height
start
=
@
file
.
tell
()
@
parseImageData
()
finish
=
@
file
.
tell
()
if
finish
isnt
start
+
@
chan
.
length
@
file
.
seek
(
start
+
@
chan
.
length
)
@
_width
=
@
layer
.
width
@
_height
=
@
layer
.
height
@
processImageData
()
parseImageData
:
->
@
compression
=
@
parseCompression
()
switch
@
compression
when
0
then
@
parseRaw
()
when
1
then
@
parseRLE
()
when
2
,
3
then
@
parseZip
()
else
@
file
.
seek
(
@
endPos
)
lib/psd/image.coffee
View file @
b4361e14
...
...
@@ -77,4 +77,4 @@ module.exports = class Image extends Module
when
3
then
@
combineRgbChannel
()
when
4
then
@
combineCmykChannel
()
@
channelData
=
null
\ No newline at end of file
@
channelData
=
null
lib/psd/image_format.coffee
View file @
b4361e14
module
.
exports
=
RAW
:
require
(
'./image_formats/raw.coffee'
)
RLE
:
require
(
'./image_formats/rle.coffee'
)
\ No newline at end of file
RLE
:
require
(
'./image_formats/rle.coffee'
)
LayerRLE
:
require
(
'./image_formats/layer_rle.coffee'
)
LayerRAW
:
require
(
'./image_formats/layer_raw.coffee'
)
lib/psd/image_formats/layer_raw.coffee
0 → 100644
View file @
b4361e14
module
.
exports
=
parseRaw
:
->
for
i
in
[
@
chanPos
...(
@
chanPos
+
@
chan
.
length
-
2
)]
@
channelData
[
i
]
=
@
file
.
readByte
()
@
chanPos
+=
(
@
chan
.
length
-
2
)
lib/psd/image_formats/layer_rle.coffee
0 → 100644
View file @
b4361e14
module
.
exports
=
parseByteCounts
:
->
@
file
.
readShort
()
for
i
in
[
0
...
@
height
()]
parseChannelData
:
->
@
lineIndex
=
0
@
decodeRLEChannel
()
lib/psd/layer.coffee
View file @
b4361e14
...
...
@@ -8,7 +8,7 @@ module.exports = class Layer extends Module
@
includes
require
(
'./layer/name.coffee'
)
@
includes
require
(
'./layer/info.coffee'
)
@
includes
require
(
'./layer/helpers.coffee'
)
#
@includes require('./layer/channel_image.coffee')
@
includes
require
(
'./layer/channel_image.coffee'
)
constructor
:
(
@
file
,
@
header
)
->
@
mask
=
{}
...
...
@@ -53,4 +53,4 @@ module.exports = class Layer extends Module
opacity
:
@
opacity
visible
:
@
visible
clipped
:
@
clipped
mask
:
@
mask
.
export
()
\ No newline at end of file
mask
:
@
mask
.
export
()
lib/psd/layer/channel_image.coffee
0 → 100644
View file @
b4361e14
ChannelImage
=
require
'../channel_image.coffee'
LazyExecute
=
require
'../lazy_execute.coffee'
module
.
exports
=
parseChannelImage
:
->
image
=
new
ChannelImage
(
@
file
,
@
header
,
@
)
@
image
=
new
LazyExecute
(
image
,
@
file
)
.
now
(
'skip'
)
.
later
(
'parse'
)
.
get
()
lib/psd/layer_mask.coffee
View file @
b4361e14
...
...
@@ -36,6 +36,8 @@ module.exports = class LayerMask
for
i
in
[
0
...
layerCount
]
@
layers
.
push
new
Layer
(
@
file
,
@
header
).
parse
()
layer
.
parseChannelImage
()
for
layer
in
@
layers
parseGlobalMask
:
->
length
=
@
file
.
readInt
()
return
if
length
<=
0
...
...
@@ -56,4 +58,4 @@ module.exports = class LayerMask
# 0 = color selected, 1 = color protected, 128 = use value per layer
mask
.
kind
=
@
file
.
readByte
()
@
file
.
seek
maskEnd
\ No newline at end of file
@
file
.
seek
maskEnd
lib/psd/node.coffee
View file @
b4361e14
...
...
@@ -4,6 +4,7 @@ _ = require 'lodash'
module
.
exports
=
class
Node
extends
Module
@
includes
require
(
'./nodes/ancestry.coffee'
)
@
includes
require
(
'./nodes/search.coffee'
)
@
includes
require
(
'./nodes/build_preview.coffee'
)
@
PROPERTIES
:
[
'name'
,
'left'
,
'right'
,
'top'
,
'bottom'
,
'height'
,
'width'
]
...
...
@@ -93,4 +94,4 @@ module.exports = class Node extends Module
@
left
=
_
.
min
(
nonEmptyChildren
.
map
((
c
)
->
c
.
left
))
or
0
@
top
=
_
.
min
(
nonEmptyChildren
.
map
((
c
)
->
c
.
top
))
or
0
@
bottom
=
_
.
max
(
nonEmptyChildren
.
map
((
c
)
->
c
.
bottom
))
or
0
@
right
=
_
.
max
(
nonEmptyChildren
.
map
((
c
)
->
c
.
right
))
or
0
\ No newline at end of file
@
right
=
_
.
max
(
nonEmptyChildren
.
map
((
c
)
->
c
.
right
))
or
0
lib/psd/nodes/build_preview.coffee
0 → 100644
View file @
b4361e14
module
.
exports
=
toPng
:
->
@
layer
.
image
.
toPng
()
saveAsPng
:
(
output
)
->
@
layer
.
image
.
saveAsPng
(
output
)
lib/psd/nodes/group.coffee
View file @
b4361e14
...
...
@@ -13,4 +13,4 @@ module.exports = class Group extends Node
export
:
->
_
.
merge
super
(),
type
:
'group'
children
:
@
_children
.
map
((
c
)
->
c
.
export
())
\ No newline at end of file
children
:
@
_children
.
map
((
c
)
->
c
.
export
())
lib/psd/nodes/layer.coffee
View file @
b4361e14
...
...
@@ -10,4 +10,4 @@ module.exports = class Layer extends Node
_
.
merge
super
,
type
:
'layer'
mask
:
@
layer
.
mask
.
export
()
image
:
{}
\ No newline at end of file
image
:
{}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment