public static Map<String, Object> compare(byte[] baselineImg, byte[] latestImg, Map<String, Object> options,
                                              Map<String, Object> defaultOptions) throws MismatchException {

        boolean allowScaling = toBool(defaultOptions.get("allowScaling"));
        ImageComparison imageComparison = new ImageComparison(baselineImg, latestImg, options, allowScaling);
        imageComparison.configure(defaultOptions);

        if (imageComparison.baselineMissing) {
            imageComparison.result.put("isBaselineMissing", true);
            throw new MismatchException("baseline image was empty or not found", imageComparison.result);
        }

        if (imageComparison.scaleMismatch) {
            imageComparison.result.put("isScaleMismatch", true);
            throw new MismatchException("latest image dimensions != baseline image dimensions", imageComparison.result);
        }

        double mismatchPercentage = 100.0;

        for (String engine : imageComparison.engines) {
            double currentMismatchPercentage;
            switch (engine) {
                case RESEMBLE:
                    currentMismatchPercentage = imageComparison.execResemble();
                    break;
                case SSIM:
                    currentMismatchPercentage = imageComparison.execSSIM();
                    break;
                default:
                    logger.error("skipping unsupported image comparison engine: {}", engine);
                    continue;
            }

            if (currentMismatchPercentage <= mismatchPercentage) {
                mismatchPercentage = currentMismatchPercentage;
            }

            if (mismatchPercentage < imageComparison.stopWhenMismatchIsLessThan) {
                break;
            }
        }

        return imageComparison.checkMismatch(mismatchPercentage);
    }
@Test
    void testDataUrl() {
        Map<String, Object> result = ImageComparison.compare(R_1x1_IMG, R_1x1_IMG, opts(), opts());
        String dataUrl = "data:image/png;base64," + R_1x1_BASE64;

        assertEquals(dataUrl, result.get("baseline"));
        assertEquals(dataUrl, result.get("latest"));
    }