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
8560364d
Commit
8560364d
authored
Mar 29, 2015
by
Ryan LeFevre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add legacy typetool
parent
dcdec792
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
103 additions
and
13 deletions
+103
-13
tree.js
examples/node/tree.js
+2
-1
psd.coffee
lib/psd.coffee
+1
-1
color.coffee
lib/psd/color.coffee
+0
-8
file.coffee
lib/psd/file.coffee
+8
-0
info.coffee
lib/psd/layer/info.coffee
+1
-0
legacy_typetool.coffee
lib/psd/layer_info/legacy_typetool.coffee
+80
-0
nested_section_divider.coffee
lib/psd/layer_info/nested_section_divider.coffee
+6
-1
typetool.coffee
lib/psd/layer_info/typetool.coffee
+5
-2
No files found.
examples/node/tree.js
View file @
8560364d
var
util
=
require
(
'util'
);
var
PSD
=
require
(
'../../'
);
var
PSD
=
require
(
'../../'
);
var
file
=
process
.
argv
[
2
]
||
'./examples/images/example.psd'
;
var
file
=
process
.
argv
[
2
]
||
'./examples/images/example.psd'
;
...
@@ -5,4 +6,4 @@ var file = process.argv[2] || './examples/images/example.psd';
...
@@ -5,4 +6,4 @@ var file = process.argv[2] || './examples/images/example.psd';
var
psd
=
PSD
.
fromFile
(
file
);
var
psd
=
PSD
.
fromFile
(
file
);
psd
.
parse
();
psd
.
parse
();
console
.
log
(
psd
.
tree
().
export
(
));
console
.
log
(
util
.
inspect
(
psd
.
tree
().
export
(),
{
depth
:
null
}
));
lib/psd.coffee
View file @
8560364d
...
@@ -60,4 +60,4 @@ module.exports = class PSD extends Module
...
@@ -60,4 +60,4 @@ module.exports = class PSD extends Module
.
ignore
(
'width'
,
'height'
)
.
ignore
(
'width'
,
'height'
)
.
get
()
.
get
()
tree
:
->
new
PSD
.
Node
.
Root
(
@
)
tree
:
->
new
PSD
.
Node
.
Root
(
@
)
\ No newline at end of file
lib/psd/color.coffee
View file @
8560364d
...
@@ -6,11 +6,3 @@ module.exports =
...
@@ -6,11 +6,3 @@ module.exports =
g
=
Util
.
clamp
(
65535
-
(
m
*
(
255
-
k
)
+
(
k
<<
8
)))
>>
8
,
0
,
255
g
=
Util
.
clamp
(
65535
-
(
m
*
(
255
-
k
)
+
(
k
<<
8
)))
>>
8
,
0
,
255
b
=
Util
.
clamp
(
65535
-
(
y
*
(
255
-
k
)
+
(
k
<<
8
)))
>>
8
,
0
,
255
b
=
Util
.
clamp
(
65535
-
(
y
*
(
255
-
k
)
+
(
k
<<
8
)))
>>
8
,
0
,
255
[
r
,
g
,
b
]
[
r
,
g
,
b
]
# def cmyk_to_rgb(c, m, y, k)
# Hash[{
# r: (65535 - (c * (255 - k) + (k << 8))) >> 8,
# g: (65535 - (m * (255 - k) + (k << 8))) >> 8,
# b: (65535 - (y * (255 - k) + (k << 8))) >> 8
# }.map { |k, v| [k, Util.clamp(v, 0, 255)] }]
# end
lib/psd/file.coffee
View file @
8560364d
{
jspack
}
=
require
'jspack'
{
jspack
}
=
require
'jspack'
iconv
=
require
'iconv-lite'
iconv
=
require
'iconv-lite'
Color
=
require
'./color.coffee'
Util
=
require
'./util.coffee'
Util
=
require
'./util.coffee'
module
.
exports
=
class
File
module
.
exports
=
class
File
...
@@ -46,3 +47,10 @@ module.exports = class File
...
@@ -46,3 +47,10 @@ module.exports = class File
readByte
:
->
@
read
(
1
)[
0
]
readByte
:
->
@
read
(
1
)[
0
]
readBoolean
:
->
@
readByte
()
isnt
0
readBoolean
:
->
@
readByte
()
isnt
0
# Reads a 32-bit color space value.
readSpaceColor
:
->
colorSpace
=
@
readShort
()
colorComponent
=
(
@
readShort
()
>>
8
)
for
i
in
[
0
...
4
]
colorSpace
:
colorSpace
,
components
:
colorComponent
lib/psd/layer/info.coffee
View file @
8560364d
...
@@ -8,6 +8,7 @@ LAYER_INFO = {
...
@@ -8,6 +8,7 @@ LAYER_INFO = {
gradientFill
:
require
(
'../layer_info/gradient_fill.coffee'
)
gradientFill
:
require
(
'../layer_info/gradient_fill.coffee'
)
layerId
:
require
(
'../layer_info/layer_id.coffee'
)
layerId
:
require
(
'../layer_info/layer_id.coffee'
)
layerNameSource
:
require
(
'../layer_info/layer_name_source.coffee'
)
layerNameSource
:
require
(
'../layer_info/layer_name_source.coffee'
)
legacyTypetool
:
require
(
'../layer_info/legacy_typetool.coffee'
)
locked
:
require
(
'../layer_info/locked.coffee'
)
locked
:
require
(
'../layer_info/locked.coffee'
)
metadata
:
require
(
'../layer_info/metadata.coffee'
)
metadata
:
require
(
'../layer_info/metadata.coffee'
)
name
:
require
(
'../layer_info/unicode_name.coffee'
)
name
:
require
(
'../layer_info/unicode_name.coffee'
)
...
...
lib/psd/layer_info/legacy_typetool.coffee
0 → 100644
View file @
8560364d
_
=
require
'lodash'
TypeTool
=
require
'./typetool.coffee'
module
.
exports
=
class
LegacyTypeTool
extends
TypeTool
@
shouldParse
:
(
key
)
->
key
is
'tySh'
constructor
:
(
layer
,
length
)
->
super
(
layer
,
length
)
@
transform
=
{}
@
faces
=
[]
@
styles
=
[]
@
lines
=
[]
@
type
=
0
@
scalingFactor
=
0
@
characterCount
=
0
@
horzPlace
=
0
@
vertPlace
=
0
@
selectStart
=
0
@
selectEnd
=
0
@
color
=
null
@
antialias
=
null
parse
:
->
@
file
.
seek
2
,
true
# Version
@
parseTransformInfo
()
# Font information
@
file
.
seek
2
,
true
facesCount
=
@
file
.
readShort
()
for
i
in
[
0
...
facesCount
]
@
faces
.
push
_
({}).
tap
(
face
)
=>
face
.
mark
=
@
file
.
readShort
()
face
.
fontType
=
@
file
.
readInt
()
face
.
fontName
=
@
file
.
readString
()
face
.
fontFamilyName
=
@
file
.
readString
()
face
.
fontStyleName
=
@
file
.
readString
()
face
.
script
=
@
file
.
readShort
()
face
.
numberAxesVector
=
@
file
.
readInt
()
face
.
vector
=
[]
for
j
in
[
0
...
face
.
numberAxesVector
]
face
.
vector
.
push
@
file
.
readInt
()
stylesCount
=
@
file
.
readShort
()
for
i
in
[
0
...
stylesCount
]
@
styles
.
push
_
({}).
tap
(
style
)
=>
style
.
mark
=
@
file
.
readShort
()
style
.
faceMark
=
@
file
.
readShort
()
style
.
size
=
@
file
.
readInt
()
style
.
tracking
=
@
file
.
readInt
()
style
.
kerning
=
@
file
.
readInt
()
style
.
leading
=
@
file
.
readInt
()
style
.
baseShift
=
@
file
.
readInt
()
style
.
autoKern
=
@
file
.
readBoolean
()
@
file
.
seek
1
,
true
style
.
rotate
=
@
file
.
readBoolean
()
@
type
=
@
file
.
readShort
()
@
scalingFactor
=
@
file
.
readInt
()
@
characterCount
=
@
file
.
readInt
()
@
horzPlace
=
@
file
.
readInt
()
@
vertPlace
=
@
file
.
readInt
()
@
selectStart
=
@
file
.
readInt
()
@
selectEnd
=
@
file
.
readInt
()
linesCount
=
@
file
.
readShort
()
for
i
in
[
0
...
linesCount
]
@
lines
.
push
_
({}).
tap
(
line
)
->
line
.
charCount
=
@
file
.
readInt
()
line
.
orientation
=
@
file
.
readShort
()
line
.
alignment
=
@
file
.
readShort
()
line
.
actualChar
=
@
file
.
readShort
()
line
.
style
=
@
file
.
readShort
()
@
color
=
@
file
.
readSpaceColor
()
@
antialias
=
@
file
.
readBoolean
()
lib/psd/layer_info/nested_section_divider.coffee
View file @
8560364d
LayerInfo
=
require
'../layer_info.coffee'
LayerInfo
=
require
'../layer_info.coffee'
# Not 100% sure what the purpose of this key is, but it seems to exist
# whenever the lsct key doesn't. Parsing this like a layer section
# divider seems to solve a lot of parsing issues with folders.
#
# See https://github.com/layervault/psd.rb/issues/38
module
.
exports
=
class
NestedSectionDivider
extends
LayerInfo
module
.
exports
=
class
NestedSectionDivider
extends
LayerInfo
@
shouldParse
:
(
key
)
->
key
is
'lsdk'
@
shouldParse
:
(
key
)
->
key
is
'lsdk'
...
@@ -14,4 +19,4 @@ module.exports = class NestedSectionDivider extends LayerInfo
...
@@ -14,4 +19,4 @@ module.exports = class NestedSectionDivider extends LayerInfo
switch
code
switch
code
when
1
,
2
then
@
isFolder
=
true
when
1
,
2
then
@
isFolder
=
true
when
3
then
@
isHidden
=
true
when
3
then
@
isHidden
=
true
\ No newline at end of file
lib/psd/layer_info/typetool.coffee
View file @
8560364d
...
@@ -27,8 +27,7 @@ module.exports = class TextElements extends LayerInfo
...
@@ -27,8 +27,7 @@ module.exports = class TextElements extends LayerInfo
parse
:
->
parse
:
->
@
version
=
@
file
.
readShort
()
@
version
=
@
file
.
readShort
()
for
name
,
index
in
TRANSFORM_VALUE
@
parseTransformInfo
()
@
transform
[
name
]
=
@
file
.
readDouble
()
@
textVersion
=
@
file
.
readShort
()
@
textVersion
=
@
file
.
readShort
()
@
descriptorVersion
=
@
file
.
readInt
()
@
descriptorVersion
=
@
file
.
readInt
()
...
@@ -46,6 +45,10 @@ module.exports = class TextElements extends LayerInfo
...
@@ -46,6 +45,10 @@ module.exports = class TextElements extends LayerInfo
for
name
,
index
in
COORDS_VALUE
for
name
,
index
in
COORDS_VALUE
@
coords
[
name
]
=
@
file
.
readDouble
()
@
coords
[
name
]
=
@
file
.
readDouble
()
parseTransformInfo
:
->
for
name
,
index
in
TRANSFORM_VALUE
@
transform
[
name
]
=
@
file
.
readDouble
()
fonts
:
->
fonts
:
->
return
[]
unless
@
engineData
?
return
[]
unless
@
engineData
?
@
engineData
.
ResourceDict
.
FontSet
.
map
(
f
)
->
f
.
Name
@
engineData
.
ResourceDict
.
FontSet
.
map
(
f
)
->
f
.
Name
...
...
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