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
67a3772c
Commit
67a3772c
authored
Jul 31, 2014
by
Ryan LeFevre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
First working example
parent
f92d255c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
12 deletions
+28
-12
export_layers.js
examples/node/export_layers.js
+7
-3
channel_image.coffee
lib/psd/channel_image.coffee
+21
-9
No files found.
examples/node/export_layers.js
View file @
67a3772c
...
@@ -4,10 +4,14 @@ var file = process.argv[2] || './examples/images/example.psd';
...
@@ -4,10 +4,14 @@ var file = process.argv[2] || './examples/images/example.psd';
var
start
=
new
Date
();
var
start
=
new
Date
();
PSD
.
open
(
file
).
then
(
function
(
psd
)
{
PSD
.
open
(
file
).
then
(
function
(
psd
)
{
return
psd
.
tree
().
descendants
().
forEach
(
function
(
node
)
{
psd
.
tree
().
descendants
().
forEach
(
function
(
node
)
{
if
(
node
.
isGroup
())
return
true
;
if
(
node
.
isGroup
())
return
true
;
return
node
.
layer
.
image
.
saveAsPng
(
"./output/#{node.name}.png"
);
node
.
layer
.
image
.
saveAsPng
(
"./output/"
+
node
.
name
+
".png"
).
catch
(
function
(
err
)
{
console
.
log
(
err
.
stack
);
});
});
});
}).
then
(
function
()
{
}).
then
(
function
()
{
console
.
log
(
"Finished in "
+
((
new
Date
())
-
start
)
+
"ms"
);
console
.
log
(
"Finished in "
+
((
new
Date
())
-
start
)
+
"ms"
);
});;
}).
catch
(
function
(
err
)
{
console
.
log
(
err
.
stack
);
});
lib/psd/channel_image.coffee
View file @
67a3772c
...
@@ -7,6 +7,9 @@ module.exports = class ChannelImage extends Image
...
@@ -7,6 +7,9 @@ module.exports = class ChannelImage extends Image
@
includes
ImageFormat
.
LayerRLE
@
includes
ImageFormat
.
LayerRLE
constructor
:
(
file
,
header
,
@
layer
)
->
constructor
:
(
file
,
header
,
@
layer
)
->
@
_width
=
@
layer
.
width
@
_height
=
@
layer
.
height
super
(
file
,
header
)
super
(
file
,
header
)
@
channelsInfo
=
@
layer
.
channelsInfo
@
channelsInfo
=
@
layer
.
channelsInfo
...
@@ -18,8 +21,8 @@ module.exports = class ChannelImage extends Image
...
@@ -18,8 +21,8 @@ module.exports = class ChannelImage extends Image
for
chan
in
@
channelsInfo
for
chan
in
@
channelsInfo
@
file
.
seek
chan
.
length
,
true
@
file
.
seek
chan
.
length
,
true
width
:
->
@
layer
.
width
width
:
->
@
_
width
height
:
->
@
layer
.
height
height
:
->
@
_
height
channels
:
->
@
layer
.
channels
channels
:
->
@
layer
.
channels
parse
:
->
parse
:
->
...
@@ -32,13 +35,13 @@ module.exports = class ChannelImage extends Image
...
@@ -32,13 +35,13 @@ module.exports = class ChannelImage extends Image
@
chan
=
chan
@
chan
=
chan
if
chan
.
id
<
-
1
if
chan
.
id
<
-
1
@
width
=
@
layer
.
mask
.
width
@
_
width
=
@
layer
.
mask
.
width
@
height
=
@
layer
.
mask
.
height
@
_
height
=
@
layer
.
mask
.
height
else
else
@
width
=
@
layer
.
width
@
_
width
=
@
layer
.
width
@
height
=
@
layer
.
height
@
_
height
=
@
layer
.
height
@
length
=
@
width
*
@
height
@
length
=
@
_width
*
@
_
height
start
=
@
file
.
tell
()
start
=
@
file
.
tell
()
@
parseImageData
()
@
parseImageData
()
...
@@ -48,7 +51,16 @@ module.exports = class ChannelImage extends Image
...
@@ -48,7 +51,16 @@ module.exports = class ChannelImage extends Image
if
finish
isnt
start
+
@
chan
.
length
if
finish
isnt
start
+
@
chan
.
length
@
file
.
seek
(
start
+
@
chan
.
length
)
@
file
.
seek
(
start
+
@
chan
.
length
)
@
width
=
@
layer
.
width
@
_
width
=
@
layer
.
width
@
height
=
@
layer
.
height
@
_
height
=
@
layer
.
height
@
processImageData
()
@
processImageData
()
parseImageData
:
->
@
compression
=
@
parseCompression
()
switch
@
compression
when
0
then
@
parseRaw
()
when
1
then
@
parseRLE
()
when
2
,
3
then
@
parseZip
()
else
@
file
.
seek
(
@
endPos
)
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