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
c3e53bea
Commit
c3e53bea
authored
Apr 22, 2015
by
Ryan LeFevre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add vector mask parsing
parent
fea60759
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
120 additions
and
0 deletions
+120
-0
file.coffee
lib/psd/file.coffee
+13
-0
info.coffee
lib/psd/layer/info.coffee
+2
-0
vector_mask.coffee
lib/psd/layer_info/vector_mask.coffee
+35
-0
path_record.coffee
lib/psd/path_record.coffee
+70
-0
No files found.
lib/psd/file.coffee
View file @
c3e53bea
...
@@ -54,3 +54,16 @@ module.exports = class File
...
@@ -54,3 +54,16 @@ module.exports = class File
colorComponent
=
(
@
readShort
()
>>
8
)
for
i
in
[
0
...
4
]
colorComponent
=
(
@
readShort
()
>>
8
)
for
i
in
[
0
...
4
]
colorSpace
:
colorSpace
,
components
:
colorComponent
colorSpace
:
colorSpace
,
components
:
colorComponent
# Adobe's lovely signed 32-bit fixed-point number with 8bits.24bits
# http://www.adobe.com/devnet-apps/photoshop/fileformatashtml/PhotoshopFileFormats.htm#50577409_17587
readPathNumber
:
->
a
=
@
readByte
()
arr
=
@
read
(
3
)
b1
=
arr
[
0
]
<<
16
b2
=
arr
[
1
]
<<
8
b3
=
arr
[
2
]
b
=
b1
|
b2
|
b3
parseFloat
(
a
,
10
)
+
parseFloat
(
b
/
Math
.
pow
(
2
,
24
),
10
)
lib/psd/layer/info.coffee
View file @
c3e53bea
...
@@ -16,6 +16,7 @@ LAYER_INFO = {
...
@@ -16,6 +16,7 @@ LAYER_INFO = {
objectEffects
:
require
(
'../layer_info/object_effects.coffee'
)
objectEffects
:
require
(
'../layer_info/object_effects.coffee'
)
sectionDivider
:
require
(
'../layer_info/section_divider.coffee'
)
sectionDivider
:
require
(
'../layer_info/section_divider.coffee'
)
typeTool
:
require
(
'../layer_info/typetool.coffee'
)
typeTool
:
require
(
'../layer_info/typetool.coffee'
)
vectorMask
:
require
(
'../layer_info/vector_mask.coffee'
)
}
}
module
.
exports
=
module
.
exports
=
...
@@ -40,6 +41,7 @@ module.exports =
...
@@ -40,6 +41,7 @@ module.exports =
unless
@
[
name
]
?
unless
@
[
name
]
?
do
(
name
)
=>
@
[
name
]
=
=>
@
adjustments
[
name
]
do
(
name
)
=>
@
[
name
]
=
=>
@
adjustments
[
name
]
@
infoKeys
.
push
key
keyParseable
=
true
keyParseable
=
true
break
break
...
...
lib/psd/layer_info/vector_mask.coffee
0 → 100644
View file @
c3e53bea
LayerInfo
=
require
'../layer_info.coffee'
PathRecord
=
require
'../path_record.coffee'
module
.
exports
=
class
VectorMask
extends
LayerInfo
@
shouldParse
:
(
key
)
->
key
in
[
'vmsk'
,
'vsms'
]
constructor
:
(
layer
,
length
)
->
super
(
layer
,
length
)
@
invert
=
null
@
notLink
=
null
@
disable
=
null
@
paths
=
[]
parse
:
->
@
file
.
seek
4
,
true
# version
tag
=
@
file
.
readInt
()
@
invert
=
(
tag
&
0x01
)
>
0
@
notLink
=
(
tag
&
(
0x01
<<
1
))
>
0
@
disable
=
(
tag
&
(
0x01
<<
2
))
>
0
# I haven't figured out yet why this is 10 and not 8.
numRecords
=
(
@
length
-
10
)
/
26
for
i
in
[
0
...
numRecords
]
record
=
new
PathRecord
(
@
file
)
record
.
parse
()
@
paths
.
push
record
export
:
->
invert
:
@
invert
notLink
:
@
notLink
disable
:
@
disable
paths
:
@
paths
.
map
(
p
)
->
p
.
export
()
lib/psd/path_record.coffee
0 → 100644
View file @
c3e53bea
_
=
require
'lodash'
module
.
exports
=
class
PathRecord
constructor
:
(
@
file
)
->
@
recordType
=
null
parse
:
->
@
recordType
=
@
file
.
readShort
()
switch
@
recordType
when
0
,
3
then
@
_readPathRecord
()
when
1
,
2
,
4
,
5
then
@
_readBezierPoint
()
when
7
then
@
_readClipboardRecord
()
when
8
then
@
_readInitialFill
()
else
@
file
.
seek
(
24
,
true
)
export
:
->
_
.
merge
{
recordType
:
@
recordType
},
switch
@
recordType
when
0
,
3
then
{
numPoints
:
@
numPoints
}
when
1
,
2
,
4
,
5
linked
:
@
linked
closed
:
(
@
recordType
in
[
1
,
2
])
preceding
:
vert
:
@
precedingVert
horiz
:
@
precedingHoriz
anchor
:
vert
:
@
anchorVert
horiz
:
@
anchorHoriz
leaving
:
vert
:
@
leavingVert
horiz
:
@
leavingHoriz
when
7
clipboard
:
top
:
@
clipboardTop
left
:
@
clipboardLeft
bottom
:
@
clipboardBottom
right
:
@
clipboardRight
resolution
:
@
clipboardResolution
when
8
then
{
initialFill
:
@
initialFill
}
else
{}
isBezierPoint
:
->
@
recordType
in
[
1
,
2
,
4
,
5
]
_readPathRecord
:
->
@
numPoints
=
@
file
.
readShort
()
@
file
.
seek
22
,
true
_readBezierPoint
:
->
@
linked
=
@
recordType
in
[
1
,
4
]
@
precedingVert
=
@
file
.
readPathNumber
()
@
precedingHoriz
=
@
file
.
readPathNumber
()
@
anchorVert
=
@
file
.
readPathNumber
()
@
anchorHoriz
=
@
file
.
readPathNumber
()
@
leavingVert
=
@
file
.
readPathNumber
()
@
leavingHoriz
=
@
file
.
readPathNumber
()
_readClipboardRecord
:
->
@
clipboardTop
=
@
file
.
readPathNumber
()
@
clipboardLeft
=
@
file
.
readPathNumber
()
@
clipboardBottom
=
@
file
.
readPathNumber
()
@
clipboardRight
=
@
file
.
readPathNumber
()
@
clipboardResolution
=
@
file
.
readPathNumber
()
@
file
.
seek
4
,
true
_readInitialFill
:
->
@
initialFill
=
@
file
.
readShort
()
@
file
.
seek
22
,
true
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