mirror of
https://github.com/Alfresco/alfresco-transform-core.git
synced 2025-08-14 17:58:27 +00:00
Image comparison resources
This commit is contained in:
@@ -10,9 +10,28 @@ ENV IMAGEMAGICK_LIB_RPM_URL=https://nexus.alfresco.com/nexus/service/local/repos
|
|||||||
ENV IMAGEMAGICK_LICENSE_FILE=https://github.com/Alfresco/acs-community-packaging/blob/master/distribution/src/main/resources/licenses/3rd-party/ImageMagick-license.txt
|
ENV IMAGEMAGICK_LICENSE_FILE=https://github.com/Alfresco/acs-community-packaging/blob/master/distribution/src/main/resources/licenses/3rd-party/ImageMagick-license.txt
|
||||||
ENV JAVA_OPTS=""
|
ENV JAVA_OPTS=""
|
||||||
|
|
||||||
COPY target/alfresco-docker-imagemagick-${env.project_version}.jar /usr/bin
|
# Image comparasion utils
|
||||||
|
RUN yum -y install epel-release && \
|
||||||
|
curl --silent --location https://rpm.nodesource.com/setup_8.x | bash - && \
|
||||||
|
yum -y install nodejs && \
|
||||||
|
yum -y install gcc-c++ make && \
|
||||||
|
yum -y install libpng12 && \
|
||||||
|
node -v && \
|
||||||
|
npm -v && \
|
||||||
|
#https://www.npmjs.com/package/mz
|
||||||
|
npm i mz && \
|
||||||
|
#https://www.npmjs.com/package/resemblejs
|
||||||
|
npm i resemblejs && \
|
||||||
|
mkdir /cmp
|
||||||
|
|
||||||
RUN ln /usr/bin/alfresco-docker-imagemagick-${env.project_version}.jar /usr/bin/alfresco-docker-imagemagick.jar && \
|
# Image comparasion file
|
||||||
|
COPY target/compare.js /cmp
|
||||||
|
COPY target/red.png /cmp
|
||||||
|
COPY target/blue.png /cmp
|
||||||
|
|
||||||
|
COPY target/alfresco-docker-imagemagick-2.0.0-RC2-SNAPSHOT.jar /usr/bin
|
||||||
|
|
||||||
|
RUN ln /usr/bin/alfresco-docker-imagemagick-2.0.0-RC2-SNAPSHOT.jar /usr/bin/alfresco-docker-imagemagick.jar && \
|
||||||
yum install -y wget && \
|
yum install -y wget && \
|
||||||
wget $IMAGEMAGICK_RPM_URL && \
|
wget $IMAGEMAGICK_RPM_URL && \
|
||||||
wget $IMAGEMAGICK_LIB_RPM_URL && \
|
wget $IMAGEMAGICK_LIB_RPM_URL && \
|
||||||
|
BIN
alfresco-docker-imagemagick/src/main/resources/blue.png
Normal file
BIN
alfresco-docker-imagemagick/src/main/resources/blue.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 144 B |
42
alfresco-docker-imagemagick/src/main/resources/compare.js
Executable file
42
alfresco-docker-imagemagick/src/main/resources/compare.js
Executable file
@@ -0,0 +1,42 @@
|
|||||||
|
#!/usr/bin/node
|
||||||
|
const compareImages = require('resemblejs/compareImages');
|
||||||
|
const fs = require("mz/fs");
|
||||||
|
|
||||||
|
|
||||||
|
// npm i mz
|
||||||
|
// npm i resemblejs
|
||||||
|
|
||||||
|
async function getDiff(img1Path, img2Path){
|
||||||
|
const options = {
|
||||||
|
output: {
|
||||||
|
errorColor: {
|
||||||
|
red: 255,
|
||||||
|
green: 0,
|
||||||
|
blue: 255
|
||||||
|
},
|
||||||
|
errorType: 'movement',
|
||||||
|
transparency: 0.3,
|
||||||
|
largeImageThreshold: 1200,
|
||||||
|
useCrossOrigin: false,
|
||||||
|
outputDiff: true
|
||||||
|
},
|
||||||
|
scaleToSameSize: true,
|
||||||
|
ignore: ['nothing', 'less', 'antialiasing', 'colors', 'alpha'],
|
||||||
|
};
|
||||||
|
|
||||||
|
// The parameters can be Node Buffers
|
||||||
|
// data is the same as usual with an additional getBuffer() function
|
||||||
|
const data = await compareImages(
|
||||||
|
await fs.readFile(img1Path),
|
||||||
|
await fs.readFile(img2Path),
|
||||||
|
options
|
||||||
|
);
|
||||||
|
|
||||||
|
console.log(data);
|
||||||
|
|
||||||
|
await fs.writeFile('./output.png', data.getBuffer());
|
||||||
|
await fs.writeFile('./output.json', JSON.stringify(data));
|
||||||
|
}
|
||||||
|
|
||||||
|
getDiff(process.argv[2], process.argv[3]);
|
||||||
|
//getDiff('/Users/p3700621/Downloads/44174363_1996471110414725_5527179798176071680_o.jpg', '/Users/p3700621/Downloads/44300765_1996444827084020_2153540260556963840_o.jpg');
|
BIN
alfresco-docker-imagemagick/src/main/resources/red.png
Normal file
BIN
alfresco-docker-imagemagick/src/main/resources/red.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.0 KiB |
Reference in New Issue
Block a user