🔬 Image analysis flyout scaffold
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -69,3 +69,4 @@ comics/
|
|||||||
userdata/
|
userdata/
|
||||||
.DS_Store
|
.DS_Store
|
||||||
erl_crash.dump
|
erl_crash.dump
|
||||||
|
temp
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ const ComicSchema = mongoose.Schema({
|
|||||||
},
|
},
|
||||||
rawFileDetails: {
|
rawFileDetails: {
|
||||||
name: { type: String, es_indexed: true },
|
name: { type: String, es_indexed: true },
|
||||||
path: String,
|
filePath: String,
|
||||||
fileSize: Number,
|
fileSize: Number,
|
||||||
extension: String,
|
extension: String,
|
||||||
containedIn: String,
|
containedIn: String,
|
||||||
|
|||||||
4551
package-lock.json
generated
4551
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -27,9 +27,11 @@
|
|||||||
"eslint": "^7.32.0",
|
"eslint": "^7.32.0",
|
||||||
"eslint-plugin-import": "^2.20.2",
|
"eslint-plugin-import": "^2.20.2",
|
||||||
"eslint-plugin-prefer-arrow": "^1.2.2",
|
"eslint-plugin-prefer-arrow": "^1.2.2",
|
||||||
|
"install": "^0.13.0",
|
||||||
"jest": "^27.2.5",
|
"jest": "^27.2.5",
|
||||||
"jest-cli": "^27.2.5",
|
"jest-cli": "^27.2.5",
|
||||||
"moleculer-repl": "^0.7.0",
|
"moleculer-repl": "^0.7.0",
|
||||||
|
"npm": "^8.4.1",
|
||||||
"ts-jest": "^25.3.0",
|
"ts-jest": "^25.3.0",
|
||||||
"ts-node": "^8.8.1",
|
"ts-node": "^8.8.1",
|
||||||
"typescript": "^3.9.10"
|
"typescript": "^3.9.10"
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
import axios from "axios";
|
||||||
import {
|
import {
|
||||||
Context,
|
Context,
|
||||||
Service,
|
Service,
|
||||||
@@ -6,9 +7,8 @@ import {
|
|||||||
ServiceSchema,
|
ServiceSchema,
|
||||||
Errors,
|
Errors,
|
||||||
} from "moleculer";
|
} from "moleculer";
|
||||||
import {
|
import path from "path";
|
||||||
resizeImage,
|
import { analyze, resizeImage } from "../utils/imagetransformation.utils";
|
||||||
} from "../utils/imagetransformation.utils";
|
|
||||||
export default class ImageTransformation extends Service {
|
export default class ImageTransformation extends Service {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
public constructor(
|
public constructor(
|
||||||
@@ -53,6 +53,20 @@ export default class ImageTransformation extends Service {
|
|||||||
return { resizeOperationStatus: resizeResult };
|
return { resizeOperationStatus: resizeResult };
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
analyze: {
|
||||||
|
rest: "POST /analyze",
|
||||||
|
params: {},
|
||||||
|
handler: async (
|
||||||
|
ctx: Context<{ imageFilePath: string }>
|
||||||
|
) => {
|
||||||
|
const url = new URL(ctx.params.imageFilePath);
|
||||||
|
const pathName = url.pathname;
|
||||||
|
const decodedImageFileURI = decodeURI(pathName);
|
||||||
|
|
||||||
|
|
||||||
|
return await analyze(path.resolve("." + decodedImageFileURI));
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
methods: {},
|
methods: {},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -52,7 +52,6 @@ import {
|
|||||||
import { unrarArchive } from "../utils/uncompression.utils";
|
import { unrarArchive } from "../utils/uncompression.utils";
|
||||||
import { extractCoverFromFile2 } from "../utils/uncompression.utils";
|
import { extractCoverFromFile2 } from "../utils/uncompression.utils";
|
||||||
import { scrapeIssuesFromDOM } from "../utils/scraping.utils";
|
import { scrapeIssuesFromDOM } from "../utils/scraping.utils";
|
||||||
import axios from "axios";
|
|
||||||
const ObjectId = require("mongoose").Types.ObjectId;
|
const ObjectId = require("mongoose").Types.ObjectId;
|
||||||
import fsExtra from "fs-extra";
|
import fsExtra from "fs-extra";
|
||||||
const through2 = require("through2");
|
const through2 = require("through2");
|
||||||
@@ -517,6 +516,7 @@ export default class ImportService extends Service {
|
|||||||
options: IExtractionOptions;
|
options: IExtractionOptions;
|
||||||
}>
|
}>
|
||||||
) {
|
) {
|
||||||
|
console.log(ctx.params);
|
||||||
return await unrarArchive(
|
return await unrarArchive(
|
||||||
ctx.params.filePath,
|
ctx.params.filePath,
|
||||||
ctx.params.options
|
ctx.params.options
|
||||||
|
|||||||
@@ -120,6 +120,14 @@ export default class QueueService extends Service {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
unarchiveComicBook: {
|
||||||
|
rest: "POST /unarchiveComicBook",
|
||||||
|
params: {},
|
||||||
|
handler: async (ctx:Context<{}>) => {
|
||||||
|
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
},
|
},
|
||||||
methods: {},
|
methods: {},
|
||||||
async started(): Promise<any> {
|
async started(): Promise<any> {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { ISharpResizedImageStats } from "threetwo-ui-typings";
|
|||||||
const imghash = require("imghash");
|
const imghash = require("imghash");
|
||||||
const leven = require("leven");
|
const leven = require("leven");
|
||||||
import { isNull, reject } from "lodash";
|
import { isNull, reject } from "lodash";
|
||||||
|
import fs from "fs";
|
||||||
|
|
||||||
export const extractMetadataFromImage = async (
|
export const extractMetadataFromImage = async (
|
||||||
imageFilePath: string
|
imageFilePath: string
|
||||||
@@ -34,11 +35,17 @@ export const resizeImage = async (
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("Image file %s resized with the following parameters: %o", imageFile, info);
|
console.log("Image file resized with the following parameters: %o", info);
|
||||||
return info;
|
return info;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const analyze = async (inputFilePath: string | Buffer) => {
|
||||||
|
const stats = await sharp(inputFilePath).stats();
|
||||||
|
// const { r, g, b } = dominant;
|
||||||
|
return stats;
|
||||||
|
}
|
||||||
|
|
||||||
export const calculateLevenshteinDistance = async (
|
export const calculateLevenshteinDistance = async (
|
||||||
imagePath1: string,
|
imagePath1: string,
|
||||||
imagePath2: string
|
imagePath2: string
|
||||||
|
|||||||
Reference in New Issue
Block a user