🌈 Added a color histogram method

This commit is contained in:
2022-02-10 09:17:46 -08:00
parent 171d64c14a
commit 163dad403c
4 changed files with 87 additions and 36 deletions

View File

@@ -121,7 +121,7 @@ export default class ApiService extends Service {
usePolling: true,
ignoreInitial: true,
atomic: true,
depth: 1,
depth: 10,
awaitWriteFinish: {
stabilityThreshold: 2000,
pollInterval: 100,

View File

@@ -8,7 +8,7 @@ import {
Errors,
} from "moleculer";
import path from "path";
import { analyze, resizeImage } from "../utils/imagetransformation.utils";
import { analyze, getColorHistogramData, resizeImage } from "../utils/imagetransformation.utils";
export default class ImageTransformation extends Service {
// @ts-ignore
public constructor(
@@ -62,9 +62,15 @@ export default class ImageTransformation extends Service {
const url = new URL(ctx.params.imageFilePath);
const pathName = url.pathname;
const decodedImageFileURI = decodeURI(pathName);
const finalImagePath = path.resolve("." + decodedImageFileURI);
return await analyze(path.resolve("." + decodedImageFileURI));
const analyzedData = await analyze(finalImagePath);
const colorHistogramData = await getColorHistogramData(finalImagePath, false);
return {
analyzedData,
colorHistogramData,
}
},
},
},

View File

@@ -157,8 +157,8 @@ export default class ImportService extends Service {
};
};
inferredMetadata: {
issue: Object,
},
issue: Object;
};
rawFileDetails: {
name: string;
};
@@ -166,7 +166,7 @@ export default class ImportService extends Service {
) {
let volumeDetails;
const comicMetadata = ctx.params;
// When an issue is added from the search CV feature
if (
comicMetadata.sourcedMetadata.comicvine &&
@@ -191,7 +191,7 @@ export default class ImportService extends Service {
resolve(data);
} else if (error) {
console.log("data", data);
console.log("error", error)
console.log("error", error);
throw new Errors.MoleculerError(
"Failed to import comic book",
400,
@@ -400,7 +400,7 @@ export default class ImportService extends Service {
];
}>
) => {
// 2a. Enqueue the Elasticsearch job
// 2a. Elasticsearch query
const { queryObjects } = ctx.params;
// construct the query for ElasticSearch
let elasticSearchQuery = {};
@@ -426,7 +426,10 @@ export default class ImportService extends Service {
{
term: {
"inferredMetadata.issue.number":
parseInt(queryObject.issueNumber, 10),
parseInt(
queryObject.issueNumber,
10
),
},
},
],
@@ -438,29 +441,8 @@ export default class ImportService extends Service {
index: "comics",
search_type: "dfs_query_then_fetch",
},
// { issueId: queryObject.issueId },
{
query: elasticSearchQuery,
// script_fields: {
// issueId: {
// script: {
// lang: "painless",
// params: {
// match: {
// issueId:
// queryObject.issueId,
// },
// },
// inline: "params.match",
// },
// },
// fileName: {
// script: {
// lang: "painless",
// inline: "params['_source']['rawFileDetails']",
// },
// },
// },
},
];
}
@@ -473,11 +455,15 @@ export default class ImportService extends Service {
elasticSearchQueries,
queryObjects,
});
// await ctx.broker.call("queue.issuesForSeries", {
// elasticSearchQueries,
// });
},
},
libraryStatistics: {
rest: "GET /libraryStatistics",
params: {},
handler: async (ctx: Context<{}>) => {
}
},
flushDB: {
rest: "POST /flushDB",
params: {},