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
969ddd48
Commit
969ddd48
authored
Apr 14, 2014
by
Ryan LeFevre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement lazy parsing
parent
c3e7db58
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
69 additions
and
10 deletions
+69
-10
psd.coffee
lib/psd.coffee
+17
-6
header.coffee
lib/psd/header.coffee
+4
-4
image.coffee
lib/psd/image.coffee
+3
-0
layer_mask.coffee
lib/psd/layer_mask.coffee
+2
-0
lazy_execute.coffee
lib/psd/lazy_execute.coffee
+39
-0
resources.coffee
lib/psd/resources.coffee
+4
-0
No files found.
lib/psd.coffee
View file @
969ddd48
fs
=
require
'fs'
File
=
require
'./psd/file.coffee'
LazyExecute
=
require
'./psd/lazy_execute.coffee'
Header
=
require
'./psd/header.coffee'
Resources
=
require
'./psd/resources.coffee'
LayerMask
=
require
'./psd/layer_mask.coffee'
...
...
@@ -29,13 +31,22 @@ module.exports = class PSD
@
header
.
parse
()
parseResources
:
->
@
resources
=
new
Resources
(
@
file
)
@
resources
.
parse
()
resources
=
new
Resources
(
@
file
)
@
resources
=
new
LazyExecute
(
resources
,
@
file
)
.
now
(
'skip'
)
.
later
(
'parse'
)
.
get
()
parseLayerMask
:
->
@
layerMask
=
new
LayerMask
(
@
file
,
@
header
)
@
layerMask
.
parse
()
layerMask
=
new
LayerMask
(
@
file
,
@
header
)
@
layerMask
=
new
LazyExecute
(
layerMask
,
@
file
)
.
now
(
'skip'
)
.
later
(
'parse'
)
.
get
()
parseImage
:
->
@
image
=
new
Image
(
@
file
,
@
header
)
@
image
.
parse
()
\ No newline at end of file
image
=
new
Image
(
@
file
,
@
header
)
@
image
=
new
LazyExecute
(
image
,
@
file
)
.
later
(
'parse'
)
.
ignore
(
'width'
,
'height'
)
.
get
()
\ No newline at end of file
lib/psd/header.coffee
View file @
969ddd48
...
...
@@ -24,8 +24,8 @@ module.exports = class Header
@
sig
=
null
@
version
=
null
@
channels
=
null
@
rows
=
null
@
cols
=
null
@
rows
=
@
height
=
null
@
cols
=
@
width
=
null
@
depth
=
null
@
mode
=
null
...
...
@@ -36,8 +36,8 @@ module.exports = class Header
@
file
.
seek
6
,
true
@
channels
=
@
file
.
readUShort
()
@
rows
=
@
file
.
readUInt
()
@
cols
=
@
file
.
readUInt
()
@
rows
=
@
height
=
@
file
.
readUInt
()
@
cols
=
@
width
=
@
file
.
readUInt
()
@
depth
=
@
file
.
readUShort
()
@
mode
=
@
file
.
readUShort
()
...
...
lib/psd/image.coffee
View file @
969ddd48
module
.
exports
=
class
Image
constructor
:
(
@
file
,
@
header
)
->
@
width
=
@
header
.
width
@
height
=
@
header
.
height
parse
:
->
console
.
log
"parse!"
\ No newline at end of file
lib/psd/layer_mask.coffee
View file @
969ddd48
...
...
@@ -6,6 +6,8 @@ module.exports = class LayerMask
@
mergedAlpha
=
false
@
globalMask
=
null
skip
:
->
@
file
.
seek
@
file
.
readInt
()
parse
:
->
maskSize
=
@
file
.
readInt
()
finish
=
maskSize
+
@
file
.
tell
()
...
...
lib/psd/lazy_execute.coffee
0 → 100644
View file @
969ddd48
module
.
exports
=
class
LazyExecute
constructor
:
(
@
obj
,
@
file
)
->
@
startPos
=
@
file
.
tell
()
@
loaded
=
false
@
loadMethod
=
null
@
loadArgs
=
[]
@
passthru
=
[]
now
:
(
method
,
args
...)
->
@
obj
[
method
].
apply
(
@
obj
,
args
)
return
@
later
:
(
method
,
args
...)
->
@
loadMethod
=
method
@
loadArgs
=
args
return
@
ignore
:
(
args
...)
->
@
passthru
.
concat
args
return
@
get
:
->
for
own
key
,
val
of
@
obj
then
do
(
key
,
val
)
=>
return
if
@
[
key
]
?
Object
.
defineProperty
@
,
key
,
get
:
->
@
load
()
if
not
@
loaded
and
not
(
key
in
@
passthru
)
@
obj
[
key
]
@
load
:
->
origPos
=
@
file
.
tell
()
@
file
.
seek
@
startPos
@
obj
[
@
loadMethod
].
apply
(
@
obj
,
@
loadArgs
)
@
file
.
seek
origPos
@
loaded
=
true
lib/psd/resources.coffee
View file @
969ddd48
...
...
@@ -4,6 +4,10 @@ module.exports = class Resources
@
typeIndex
=
{}
@
length
=
null
skip
:
->
@
length
=
@
file
.
readInt
()
@
file
.
seek
@
length
,
true
parse
:
->
@
length
=
@
file
.
readInt
()
@
file
.
seek
@
length
,
true
\ 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