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
f92d255c
Commit
f92d255c
authored
Jul 31, 2014
by
Ryan LeFevre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More work towards channel images
parent
860aea39
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
43 additions
and
11 deletions
+43
-11
export_layers.js
examples/node/export_layers.js
+13
-0
channel_image.coffee
lib/psd/channel_image.coffee
+8
-6
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
channel_image.coffee
lib/psd/layer/channel_image.coffee
+1
-0
node.coffee
lib/psd/node.coffee
+2
-1
group.coffee
lib/psd/nodes/group.coffee
+1
-1
layer.coffee
lib/psd/nodes/layer.coffee
+1
-1
No files found.
examples/node/export_layers.js
0 → 100644
View file @
f92d255c
var
PSD
=
require
(
'../../'
);
var
file
=
process
.
argv
[
2
]
||
'./examples/images/example.psd'
;
var
start
=
new
Date
();
PSD
.
open
(
file
).
then
(
function
(
psd
)
{
return
psd
.
tree
().
descendants
().
forEach
(
function
(
node
)
{
if
(
node
.
isGroup
())
return
true
;
return
node
.
layer
.
image
.
saveAsPng
(
"./output/#{node.name}.png"
);
});
}).
then
(
function
()
{
console
.
log
(
"Finished in "
+
((
new
Date
())
-
start
)
+
"ms"
);
});;
lib/psd/channel_image.coffee
View file @
f92d255c
_
=
require
'lodash'
_
=
require
'lodash'
Image
=
require
'./image.coffee'
Image
=
require
'./image.coffee'
ImageFormat
=
require
'./image_format.coffee'
module
.
exports
=
class
ChannelImage
extends
Image
module
.
exports
=
class
ChannelImage
extends
Image
@
includes
ImageFormat
.
LayerRAW
constructor
:
(
file
,
header
,
@
layer
)
->
@
includes
ImageFormat
.
LayerRLE
@
width
=
@
layer
.
width
@
height
=
@
layer
.
height
constructor
:
(
file
,
header
,
@
layer
)
->
super
(
file
,
header
)
super
(
file
,
header
)
@
channelsInfo
=
@
layer
.
channelsInfo
@
channelsInfo
=
@
layer
.
channelsInfo
...
@@ -18,6 +18,8 @@ module.exports = class ChannelImage extends Image
...
@@ -18,6 +18,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
height
:
->
@
layer
.
height
channels
:
->
@
layer
.
channels
channels
:
->
@
layer
.
channels
parse
:
->
parse
:
->
...
...
lib/psd/image.coffee
View file @
f92d255c
...
@@ -77,4 +77,4 @@ module.exports = class Image extends Module
...
@@ -77,4 +77,4 @@ module.exports = class Image extends Module
when
3
then
@
combineRgbChannel
()
when
3
then
@
combineRgbChannel
()
when
4
then
@
combineCmykChannel
()
when
4
then
@
combineCmykChannel
()
@
channelData
=
null
@
channelData
=
null
\ No newline at end of file
lib/psd/image_format.coffee
View file @
f92d255c
module
.
exports
=
module
.
exports
=
RAW
:
require
(
'./image_formats/raw.coffee'
)
RAW
:
require
(
'./image_formats/raw.coffee'
)
RLE
:
require
(
'./image_formats/rle.coffee'
)
RLE
:
require
(
'./image_formats/rle.coffee'
)
\ No newline at end of file
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 @
f92d255c
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 @
f92d255c
module
.
exports
=
parseByteCounts
:
->
@
file
.
readShort
()
for
i
in
[
0
...
@
height
()]
parseChannelData
:
->
@
lineIndex
=
0
@
decodeRLEChannel
()
lib/psd/layer/channel_image.coffee
View file @
f92d255c
ChannelImage
=
require
'../channel_image.coffee'
ChannelImage
=
require
'../channel_image.coffee'
LazyExecute
=
require
'../lazy_execute.coffee'
module
.
exports
=
module
.
exports
=
parseChannelImage
:
->
parseChannelImage
:
->
...
...
lib/psd/node.coffee
View file @
f92d255c
...
@@ -4,6 +4,7 @@ _ = require 'lodash'
...
@@ -4,6 +4,7 @@ _ = require 'lodash'
module
.
exports
=
class
Node
extends
Module
module
.
exports
=
class
Node
extends
Module
@
includes
require
(
'./nodes/ancestry.coffee'
)
@
includes
require
(
'./nodes/ancestry.coffee'
)
@
includes
require
(
'./nodes/search.coffee'
)
@
includes
require
(
'./nodes/search.coffee'
)
# @includes require('./nodes/build_preview.coffee')
@
PROPERTIES
:
[
'name'
,
'left'
,
'right'
,
'top'
,
'bottom'
,
'height'
,
'width'
]
@
PROPERTIES
:
[
'name'
,
'left'
,
'right'
,
'top'
,
'bottom'
,
'height'
,
'width'
]
...
@@ -93,4 +94,4 @@ module.exports = class Node extends Module
...
@@ -93,4 +94,4 @@ module.exports = class Node extends Module
@
left
=
_
.
min
(
nonEmptyChildren
.
map
((
c
)
->
c
.
left
))
or
0
@
left
=
_
.
min
(
nonEmptyChildren
.
map
((
c
)
->
c
.
left
))
or
0
@
top
=
_
.
min
(
nonEmptyChildren
.
map
((
c
)
->
c
.
top
))
or
0
@
top
=
_
.
min
(
nonEmptyChildren
.
map
((
c
)
->
c
.
top
))
or
0
@
bottom
=
_
.
max
(
nonEmptyChildren
.
map
((
c
)
->
c
.
bottom
))
or
0
@
bottom
=
_
.
max
(
nonEmptyChildren
.
map
((
c
)
->
c
.
bottom
))
or
0
@
right
=
_
.
max
(
nonEmptyChildren
.
map
((
c
)
->
c
.
right
))
or
0
@
right
=
_
.
max
(
nonEmptyChildren
.
map
((
c
)
->
c
.
right
))
or
0
\ No newline at end of file
lib/psd/nodes/group.coffee
View file @
f92d255c
...
@@ -13,4 +13,4 @@ module.exports = class Group extends Node
...
@@ -13,4 +13,4 @@ module.exports = class Group extends Node
export
:
->
export
:
->
_
.
merge
super
(),
_
.
merge
super
(),
type
:
'group'
type
:
'group'
children
:
@
_children
.
map
((
c
)
->
c
.
export
())
children
:
@
_children
.
map
((
c
)
->
c
.
export
())
\ No newline at end of file
lib/psd/nodes/layer.coffee
View file @
f92d255c
...
@@ -10,4 +10,4 @@ module.exports = class Layer extends Node
...
@@ -10,4 +10,4 @@ module.exports = class Layer extends Node
_
.
merge
super
,
_
.
merge
super
,
type
:
'layer'
type
:
'layer'
mask
:
@
layer
.
mask
.
export
()
mask
:
@
layer
.
mask
.
export
()
image
:
{}
image
:
{}
\ No newline at end of file
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