Horizontal compare - #93
Conversation
|
Thanks a lot |
|
I would love this feature! |
How I can help you? |
I want to push your PR. Your feature would be very helpful for me. That's all :) |
I don't know why PR is still open. You can contact manteiner of repo. |
|
Hi there, |
|
|
||
| @Override | ||
| public int getNrOfImagesToCache() { | ||
| return config.getInt("imageCacheSizeCount"); |
There was a problem hiding this comment.
This should not be set to a fixed value. Revert to the previous code, please
|
|
||
| @Override | ||
| public boolean getEnableHorizontalCompareOutput() { | ||
| return false; |
There was a problem hiding this comment.
Should not be a fixed value but should be read from the config instead, so it's configurable via a config file
| private Integer dpi; | ||
| private Boolean addEqualPagesToResult; | ||
| private Boolean failOnMissingIgnoreFile; | ||
| private Boolean enableHorizontalCompareOutput=false; |
There was a problem hiding this comment.
Should not be initialized to false here.
| } | ||
|
|
||
| public boolean getEnableHorizontalCompareOutput() { | ||
| return enableHorizontalCompareOutput; |
There was a problem hiding this comment.
Should include fallback handling to be consistent with the config chain.
| Utilities.shutdownAndAwaitTermination(swapExecutor, "Swap"); | ||
| try { | ||
| LOG.trace("Merging..."); | ||
| LOG.info("Merging..."); |
There was a problem hiding this comment.
Please leave this at trace level to reduce logging noise for normal users
| if(this.environment.getEnableHorizontalCompareOutput()) { | ||
| this.addPageWithHorizontalCompare(diffCalculator, pageIndex, expectedImage, actualImage, diffImage); | ||
| }else { |
There was a problem hiding this comment.
Please use the same formatting/spacing as the rest of the code
| @@ -0,0 +1,61 @@ | |||
| package x.team.tool; | |||
There was a problem hiding this comment.
Please use a package in de.red6.pdfcompare
| package x.team.poc; | ||
|
|
||
| import java.awt.Color; | ||
|
|
||
| import de.redsix.pdfcompare.CompareResult; | ||
| import de.redsix.pdfcompare.PdfComparator; | ||
| import de.redsix.pdfcompare.env.SimpleEnvironment; | ||
|
|
||
| public class POC { | ||
|
|
||
| public static void main(String[] args) { | ||
| try { | ||
|
|
||
| PdfComparator compare = new PdfComparator("input/expected.pdf", "input/actual.pdf") | ||
| .withEnvironment(new SimpleEnvironment().setActualColor(Color.red) | ||
| .setExpectedColor(Color.white).setAddEqualPagesToResult(true) | ||
| .setEnableHorizontalCompareOutput(true)); | ||
|
|
||
| CompareResult result = compare.compare(); | ||
| result .writeTo("output/diffOutput"); | ||
| if (result.isNotEqual()) { | ||
| System.out.println("Ho trovato differenza!"); | ||
| } | ||
| if (result.isEqual()) { | ||
| System.out.println("Non ho trovato nessuna differenza!"); | ||
| } | ||
| result.getDifferences(); | ||
| } catch (Exception e) { | ||
| e.printStackTrace(); | ||
| } | ||
| } | ||
|
|
||
| } |
There was a problem hiding this comment.
Please write a proper integration test for this scenarios.
English in code and comments only please.
| } | ||
|
|
||
| @Override | ||
| public void addPageWithHorizontalCompare(PageDiffCalculator diffCalculator, int pageIndex, |
There was a problem hiding this comment.
This method is not unit tested. Please write tests for it.
|
|
||
| public class MergeImages { | ||
|
|
||
| public ImageWithDimension mergeOnLeft(ImageWithDimension left, ImageWithDimension right, String headerLeft, |
There was a problem hiding this comment.
This code is not unit tested. Please write tests for it.
|
@v3g3t4x I quickly added some immediate findings. Could you clean those up please? |
| LOG.info("Differences found at { page: {}, x1: {}, y1: {}, x2: {}, y2: {} }", page + 1, diffAreaX1, diffAreaY1, diffAreaX2, | ||
| LOG.debug("Differences found at { page: {}, x1: {}, y1: {}, x2: {}, y2: {} }", page + 1, diffAreaX1, diffAreaY1, diffAreaX2, |
| Objects.requireNonNull(actualImage, "actualImage is null"); | ||
| Objects.requireNonNull(diffImage, "diffImage is null"); | ||
| this.hasDifferenceInExclusion |= diffCalculator.differencesFoundInExclusion(); | ||
| diffPercentages.put(pageIndex, diffCalculator.getDifferenceInPercent()); |
There was a problem hiding this comment.
This line is missing in the else-block.
|
@v3g3t4x I want to support the development, if you wish. Please add me as maintainer to your PR. edit: Most of the work is done, but i can't push to your PR. I hope we find a solution :) |
So am i ;-) But he did most of the work, so i want to give him the credits. |
Added horizontal compare.
Gived 2 pdf generate a third pdf where for each page you can find on the left the page of first pdf and on the right the page of the second pdf.
Here an example on how use it...use setEnableHorizontalCompareOutput..
PdfComparator compare = new PdfComparator("input/input1.pdf", "input/input2.pdf");
boolean flagLeftRight = true;
compare.headerLeft = "LEFT";
compare.headerRight = "RIGHT";
compare.withEnvironment(new SimpleEnvironment().setActualColor(Color.red).setParallelProcessing(true)
.setMaxImageSize(100000).setDocumentCacheSize(0).setOverallTimeout(15)
.setExpectedColor(Color.CYAN).setAddEqualPagesToResult(true).setDPI(DPI)
.setEnableHorizontalCompareOutput(flagLeftRight).setAllowedDiffInPercent(pixel));
CompareResult result = compare.compare();