🌈 Added a color histogram method
This commit is contained in:
@@ -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,
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user