RED-7075: Watermark Removal PMD errors fixed and logs

This commit is contained in:
RaphaelArnold 2023-08-02 10:27:31 +02:00
parent 51b6307f91
commit 7a9c00e6cf
3 changed files with 9 additions and 3 deletions

View File

@ -179,8 +179,8 @@ public class ElementFeatures {
int distance = 0;
int maxLength = Math.max(this.hashOfImage.length(), hash2.length());
for (int i = 0; i < maxLength; i++) {
char char1 = (i < this.hashOfImage.length()) ? this.hashOfImage.charAt(i) : '0';
char char2 = (i < hash2.length()) ? hash2.charAt(i) : '0';
char char1 = i < this.hashOfImage.length() ? this.hashOfImage.charAt(i) : '0';
char char2 = i < hash2.length() ? hash2.charAt(i) : '0';
if (char1 != char2) {
distance++;
}

View File

@ -97,7 +97,7 @@ public class ImageHashFactory {
int leftPixel = resizedImage.getRGB(x, y);
int rightPixel = resizedImage.getRGB(x + 1, y);
hash <<= 1;
hash |= (leftPixel < rightPixel) ? 1 : 0;
hash |= leftPixel < rightPixel ? 1 : 0;
}
}

View File

@ -47,6 +47,12 @@ public class WatermarkRemovalService {
List<ElementFeatures> watermarkElementFeatures = filterSameFormObjectsOccuringOnMostPages(formObjectsForPages);
if(watermarkElementFeatures.size() > 0){
log.info("Watermark found and will be removed!");
} else {
log.info("No watermark found!");
}
removeAllWatermarks(pdfDoc, watermarkElementFeatures);
try {