# qa-image-comparison

> QA Image Comparison is a powerful library for comparing images, designed to aid in quality assurance processes. It provides utilities to compare images provided as base64 strings, from file paths, or directly using Jimp objects. With easy-to-use methods a

Latest version **1.0.5** (published 2024-03-17) · Apache-2.0 license license · 0 weekly downloads

## Install

```sh
npm install qa-image-comparison
pnpm add qa-image-comparison
yarn add qa-image-comparison
bun add qa-image-comparison
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2024-03-17 |
| First published | 2024-03-16 |
| Weekly downloads | 0 |
| License | Apache-2.0 license |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 14.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Radoslav Radoslavov |
| Maintainers | radobg |
| Keywords | automation, automation qa, image, images, comparison, visual, regression, testing, image comparison for selenium |

## Links

- npm: https://www.npmjs.com/package/qa-image-comparison
- npm.io page: https://npm.io/package/qa-image-comparison

## Dependencies (3)

- [jimp](https://npm.io/package/jimp.md) ^0.22.12
- [typescript](https://npm.io/package/typescript.md) ^5.4.2
- [@types/jimp](https://npm.io/package/@types/jimp.md) ^0.2.28

## Alternatives

- [@snazzah/davey](https://npm.io/package/@snazzah/davey.md) — 1.5M weekly downloads
- [@vendure/testing](https://npm.io/package/@vendure/testing.md) — 8.3K weekly downloads
- [vue-simple-context-menu](https://npm.io/package/vue-simple-context-menu.md) — 6.6K weekly downloads
- [cypress-webpack-preprocessor-v5](https://npm.io/package/cypress-webpack-preprocessor-v5.md) — 2.1K weekly downloads
- [@backstage/plugin-catalog-backend-module-puppetdb](https://npm.io/package/@backstage/plugin-catalog-backend-module-puppetdb.md) — 1.3K weekly downloads

## Recent versions

- 1.0.5 (latest) — 2024-03-17
- 1.0.4 — 2024-03-17
- 1.0.2 — 2024-03-16
- 1.0.1 — 2024-03-16
- 1.0.0 — 2024-03-16

## README

# QA Image Comparison

QA Image Comparison is a library for comparing images, designed for quality assurance purposes. It leverages the Jimp library to provide utilities for comparing images provided as base64 strings, from file paths, or directly using Jimp objects.

[![Node.js Package](https://github.com/RadoBG1/qa-image-comparison/actions/workflows/npm-publish.yml/badge.svg)](https://github.com/RadoBG1/qa-image-comparison/actions/workflows/npm-publish.yml)
## Installation

You can install the library via npm:

```bash
npm install qa-image-comparison
```

## Usage
### Initialization
```typescript 
import { CompareImages } from 'qa-image-comparison';

const comparer = new CompareImages();
```
### Comparing Images from Base64 Strings
```typescript 
const image1Base64 = '...'; // Base64 string of the first image
const image2Base64 = '...'; // Base64 string of the second image

const result = await comparer.CompareImagesByBase64String(image1Base64, image2Base64);
console.log('Images match:', result);
```
### Comparing Images from Disk

```typescript
const imagePath1 = 'path/to/image1.jpg';
const imagePath2 = 'path/to/image2.jpg';

const result = await comparer.CompareImagesFromDisk(imagePath1, imagePath2);
console.log('Images match:', result);
```
### Comparing Jimp Images Directly
```typescript

import Jimp from 'jimp';

const image1 = await Jimp.read('path/to/image1.jpg');
const image2 = await Jimp.read('path/to/image2.jpg');

const result = await comparer.CompareJimpImages(image1, image2);
console.log('Images match:', result);
```
## API Reference
### CompareImages Class
#### CompareImagesByBase64String(imageExpectedString: string, imageActualString: string): Promise<boolean>

Compares two images provided as base64 strings.

imageExpectedString: Base64 string of the expected image.
imageActualString: Base64 string of the actual image to be compared.

Returns a Promise resolving to true if images match, false otherwise.

#### CompareImagesFromDisk(imageExpectedPath: string, imageActualPath: string): Promise<boolean>

Compares images from file paths.

imageExpectedPath: Path to the expected image file.
imageActualPath: Path to the actual image file to be compared.

Returns a Promise resolving to true if images match, false otherwise.

#### CompareJimpImages(imageExpected: Jimp, imageActual: Jimp): Promise<boolean>

Compares two Jimp images directly.

imageExpected: The expected Jimp image.
imageActual: The actual Jimp image to be compared.

Returns true if images match, false otherwise.

## License
This library is licensed under the Apache-2.0 license.

## Version
Current version: 1.0.3

## Author
Radoslav Radoslavov

---
_Source: https://npm.io/package/qa-image-comparison · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
