|
@@ -1,13 +1,8 @@
|
|
-import {
|
|
|
|
- getInputDir,
|
|
|
|
- getOutputDir,
|
|
|
|
- makeDirSync
|
|
|
|
-} from "./env";
|
|
|
|
|
|
+import { getInputDir, getOutputDir, makeDirSync } from "./env";
|
|
import { randomCode } from "./utils";
|
|
import { randomCode } from "./utils";
|
|
const fs = require("fs");
|
|
const fs = require("fs");
|
|
const path = require("path");
|
|
const path = require("path");
|
|
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* 旋转图片,并保存为正式文件
|
|
* 旋转图片,并保存为正式文件
|
|
* @param {*} imgPath 图片路径
|
|
* @param {*} imgPath 图片路径
|
|
@@ -17,20 +12,8 @@ const path = require("path");
|
|
async function saveOutputImage(imgPath, paperInfo, collectConfig) {
|
|
async function saveOutputImage(imgPath, paperInfo, collectConfig) {
|
|
// console.log(collectConfig);
|
|
// console.log(collectConfig);
|
|
const outputOriginPath = saveOriginImage(imgPath, paperInfo);
|
|
const outputOriginPath = saveOriginImage(imgPath, paperInfo);
|
|
- const outputFormalPath = await saveFormalImage(
|
|
|
|
- imgPath,
|
|
|
|
- paperInfo,
|
|
|
|
- collectConfig
|
|
|
|
- );
|
|
|
|
- const outputSlicelPath = await saveSliceImage(
|
|
|
|
- imgPath,
|
|
|
|
- paperInfo,
|
|
|
|
- collectConfig
|
|
|
|
- ).catch(() => {});
|
|
|
|
|
|
|
|
- if (outputSlicelPath && outputFormalPath)
|
|
|
|
- return { outputSlicelPath, outputFormalPath, outputOriginPath };
|
|
|
|
- return Promise.reject("试卷保存失败");
|
|
|
|
|
|
+ return outputOriginPath;
|
|
}
|
|
}
|
|
|
|
|
|
function saveOriginImage(imgPath, paperInfo) {
|
|
function saveOriginImage(imgPath, paperInfo) {
|
|
@@ -41,9 +24,6 @@ function saveOriginImage(imgPath, paperInfo) {
|
|
return outputOriginPath;
|
|
return outputOriginPath;
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
function getOutputImagePath(paperInfo, type) {
|
|
function getOutputImagePath(paperInfo, type) {
|
|
const outputDir = path.join(
|
|
const outputDir = path.join(
|
|
getOutputDir(type),
|
|
getOutputDir(type),
|
|
@@ -80,7 +60,4 @@ function getEarliestFile(dir) {
|
|
};
|
|
};
|
|
}
|
|
}
|
|
|
|
|
|
-export {
|
|
|
|
- saveOutputImage,
|
|
|
|
- getEarliestFile,
|
|
|
|
-};
|
|
|
|
|
|
+export { saveOutputImage, getEarliestFile };
|