Commit 8417141f authored by rockyl's avatar rockyl

修复png内容为空的情况

parent 45dacb44
......@@ -280,24 +280,26 @@ async function execute$1(psdFile, options) {
const uuid = generateUUID();
const ext = '.png';
properties.source = 'asset://' + uuid;
const imageFilePath = path.join(imagesPath, uuid + ext);
await fs.ensureDir(path.dirname(imageFilePath));
let png = node.origin.toPng();
let buffer = await savePng(png, imageFilePath);
let buffer = await savePng(png, imageFilePath).catch(e=>{});
//await node.origin.saveAsPng(imageFilePath);
const hashFileName = hash(buffer);
const hashFilePath = path.join(imagesPath, hashFileName + ext);
await fs.rename(imageFilePath, hashFilePath);
if(buffer){
properties.source = 'asset://' + uuid;
const hashFileName = hash(buffer);
const hashFilePath = path.join(imagesPath, hashFileName + ext);
await fs.rename(imageFilePath, hashFilePath);
assets.push({
name,
ext,
uuid,
hash: hashFileName,
});
assets.push({
name,
ext,
uuid,
hash: hashFileName,
});
}
}
}
......
This diff is collapsed.
......@@ -286,24 +286,26 @@ async function execute$1(psdFile, options) {
const uuid = generateUUID();
const ext = '.png';
properties.source = 'asset://' + uuid;
const imageFilePath = path.join(imagesPath, uuid + ext);
await fs.ensureDir(path.dirname(imageFilePath));
let png = node.origin.toPng();
let buffer = await savePng(png, imageFilePath);
let buffer = await savePng(png, imageFilePath).catch(e=>{});
//await node.origin.saveAsPng(imageFilePath);
const hashFileName = hash(buffer);
const hashFilePath = path.join(imagesPath, hashFileName + ext);
await fs.rename(imageFilePath, hashFilePath);
if(buffer){
properties.source = 'asset://' + uuid;
const hashFileName = hash(buffer);
const hashFilePath = path.join(imagesPath, hashFileName + ext);
await fs.rename(imageFilePath, hashFilePath);
assets.push({
name,
ext,
uuid,
hash: hashFileName,
});
assets.push({
name,
ext,
uuid,
hash: hashFileName,
});
}
}
}
......
This diff is collapsed.
......@@ -286,24 +286,26 @@
const uuid = generateUUID();
const ext = '.png';
properties.source = 'asset://' + uuid;
const imageFilePath = path.join(imagesPath, uuid + ext);
await fs.ensureDir(path.dirname(imageFilePath));
let png = node.origin.toPng();
let buffer = await savePng(png, imageFilePath);
let buffer = await savePng(png, imageFilePath).catch(e=>{});
//await node.origin.saveAsPng(imageFilePath);
const hashFileName = hash(buffer);
const hashFilePath = path.join(imagesPath, hashFileName + ext);
await fs.rename(imageFilePath, hashFilePath);
if(buffer){
properties.source = 'asset://' + uuid;
const hashFileName = hash(buffer);
const hashFilePath = path.join(imagesPath, hashFileName + ext);
await fs.rename(imageFilePath, hashFilePath);
assets.push({
name,
ext,
uuid,
hash: hashFileName,
});
assets.push({
name,
ext,
uuid,
hash: hashFileName,
});
}
}
}
......
This diff is collapsed.
......@@ -73,24 +73,26 @@ export async function execute(psdFile, options) {
const uuid = generateUUID();
const ext = '.png';
properties.source = 'asset://' + uuid;
const imageFilePath = path.join(imagesPath, uuid + ext);
await fs.ensureDir(path.dirname(imageFilePath));
let png = node.origin.toPng();
let buffer = await savePng(png, imageFilePath);
let buffer = await savePng(png, imageFilePath).catch(e=>{});
//await node.origin.saveAsPng(imageFilePath);
const hashFileName = hash(buffer);
const hashFilePath = path.join(imagesPath, hashFileName + ext);
await fs.rename(imageFilePath, hashFilePath);
if(buffer){
properties.source = 'asset://' + uuid;
const hashFileName = hash(buffer);
const hashFilePath = path.join(imagesPath, hashFileName + ext);
await fs.rename(imageFilePath, hashFilePath);
assets.push({
name,
ext,
uuid,
hash: hashFileName,
});
assets.push({
name,
ext,
uuid,
hash: hashFileName,
});
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment