Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
psd-parse
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
劳工
psd-parse
Commits
959d4db9
Commit
959d4db9
authored
Jan 08, 2020
by
rockyl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
提交
parent
9a995b61
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
13 deletions
+19
-13
generator.cjs.js
samples/zeroing-demo/generator.cjs.js
+17
-11
generator.cjs.js.map
samples/zeroing-demo/generator.cjs.js.map
+1
-1
generator.js
samples/zeroing-demo/generator.js
+1
-1
No files found.
samples/zeroing-demo/generator.cjs.js
View file @
959d4db9
...
...
@@ -83,6 +83,7 @@ async function execute(psdFile, options) {
};
const
assets
=
[];
const
imageHashMap
=
{};
await
walkNode
(
tree
,
async
function
(
node
,
parent
)
{
const
{
name
,
x
,
y
,
width
,
height
,
alpha
,
visible
,
origin
:
{
layer
,
layer
:
{
typeTool
,
solidColor
}}}
=
node
;
...
...
@@ -146,7 +147,7 @@ async function execute(psdFile, options) {
}
else
{
viewNode
.
type
=
'image'
;
cons
t
uuid
=
generateUUID
();
le
t
uuid
=
generateUUID
();
const
ext
=
'.png'
;
const
imageFilePath
=
path
.
join
(
imagesPath
,
uuid
+
ext
);
...
...
@@ -157,18 +158,23 @@ async function execute(psdFile, options) {
//await node.origin.saveAsPng(imageFilePath);
if
(
buffer
)
{
properties
.
source
=
'asset://'
+
uuid
;
const
fileNameHash
=
hash
(
buffer
);
if
(
imageHashMap
.
hasOwnProperty
(
fileNameHash
))
{
uuid
=
imageHashMap
[
fileNameHash
];
}
else
{
imageHashMap
[
fileNameHash
]
=
uuid
;
assets
.
push
({
name
,
ext
,
uuid
,
hash
:
fileNameHash
,
});
}
const
hashFileName
=
hash
(
buffer
);
const
hashFilePath
=
path
.
join
(
imagesPath
,
hashFileName
+
ext
);
const
hashFilePath
=
path
.
join
(
imagesPath
,
fileNameHash
+
ext
);
await
fs
.
rename
(
imageFilePath
,
hashFilePath
);
assets
.
push
({
name
,
ext
,
uuid
,
hash
:
hashFileName
,
});
properties
.
source
=
'asset://'
+
uuid
;
}
}
}
...
...
@@ -211,7 +217,7 @@ function savePng(png, output) {
(
async
function
generate
()
{
const
imagesPath
=
'zeroing-demo/images_'
+
Date
.
now
();
const
{
view
,
assets
}
=
await
execute
(
'psd/test
3
.psd'
,
{
const
{
view
,
assets
}
=
await
execute
(
'psd/test
4
.psd'
,
{
imagesPath
,
});
...
...
samples/zeroing-demo/generator.cjs.js.map
View file @
959d4db9
This diff is collapsed.
Click to expand it.
samples/zeroing-demo/generator.js
View file @
959d4db9
...
...
@@ -7,7 +7,7 @@ import {toZeroing} from "../../src/index";
(
async
function
generate
()
{
const
imagesPath
=
'zeroing-demo/images_'
+
Date
.
now
();
const
{
view
,
assets
}
=
await
toZeroing
(
'psd/test
3
.psd'
,
{
const
{
view
,
assets
}
=
await
toZeroing
(
'psd/test
4
.psd'
,
{
imagesPath
,
});
...
...
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