@types/resemblejs
Advanced tools
| import { ComparisonOptions, ComparisonResult } from '.'; | ||
| export = compareImages; | ||
| /** | ||
| * The API under Node is the same as on the `resemble.compare` but promise based | ||
| */ | ||
| declare function compareImages( | ||
| image1: string | ImageData | Buffer, | ||
| image2: string | ImageData | Buffer, | ||
| options: ComparisonOptions, | ||
| ): Promise<ComparisonResult>; |
+151
-71
@@ -1,6 +0,8 @@ | ||
| // Type definitions for Resemble.js v3.2.5 | ||
| // Type definitions for Resemble.js v4.1.0 | ||
| // Project: https://github.com/rsmbl/Resemble.js | ||
| // Definitions by: Tim Perry <https://github.com/pimterry> | ||
| // Definitions by: GreenYun <https://github.com/Greenyun> | ||
| // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | ||
| /// <reference path="compareImages.d.ts" /> | ||
| declare global { | ||
@@ -16,34 +18,13 @@ // workaround for the Buffer type as referencing all node types breaks dependent projects | ||
| * Retrieve basic analysis for a single image (add compareTo to compare with another). | ||
| * | ||
| * @param image - The image to analyze. Accepts a URL to an image, a Data URI, a ImageData object, or a Buffer. | ||
| */ | ||
| declare function Resemble(image: string | ImageData | Buffer): Resemble.ResembleAnalysis; | ||
| declare function Resemble(image: string | ImageData | Buffer): Resemble.Analysis; | ||
| declare namespace Resemble { | ||
| /** | ||
| * Set the resemblance image output style | ||
| */ | ||
| function outputSettings(settings: OutputSettings): typeof Resemble; | ||
| interface OutputSettings { | ||
| errorColor?: { | ||
| red: number; | ||
| green: number; | ||
| blue: number; | ||
| } | undefined; | ||
| errorType?: 'flat' | 'movement' | 'flatDifferenceIntensity' | 'movementDifferenceIntensity' | 'diffOnly' | undefined; | ||
| errorPixel?: ((px: number[], offset: number, d1: ResembleColor, d2: ResembleColor) => void) | undefined; | ||
| transparency?: number | undefined; | ||
| largeImageThreshold?: number | undefined; | ||
| useCrossOrigin?: boolean | undefined; | ||
| boundingBox?: ResembleBox | undefined; | ||
| ignoredBox?: ResembleBox | undefined; | ||
| boundingBoxes?: ResembleBox[] | undefined; | ||
| ignoredBoxes?: ResembleBox[] | undefined; | ||
| ignoreAreasColoredWith?: ResembleColor | undefined; | ||
| } | ||
| interface ResembleAnalysis { | ||
| interface Analysis { | ||
| /** | ||
| * Run the analysis on this image and get the result | ||
| */ | ||
| onComplete(callback: (result: ResembleAnalysisResult) => void): void; | ||
| onComplete(callback: (result: AnalysisResult) => void): void; | ||
@@ -53,6 +34,11 @@ /** | ||
| */ | ||
| compareTo(fileData: string | ImageData | Buffer): ResembleComparison; | ||
| compareTo(fileData: string | ImageData | Buffer): Comparison; | ||
| /** | ||
| * Set the resemblance image output style | ||
| */ | ||
| outputSettings(settings: OutputSettings): Analysis; | ||
| } | ||
| interface ResembleAnalysisResult { | ||
| interface AnalysisResult { | ||
| red: number; | ||
@@ -62,25 +48,85 @@ green: number; | ||
| brightness: number; | ||
| white: number; | ||
| black: number; | ||
| } | ||
| interface ResembleComparison { | ||
| interface Comparison { | ||
| /** | ||
| * Run the analysis and get the comparison result | ||
| */ | ||
| onComplete(callback: (result: ResembleComparisonResult) => void): void; | ||
| onComplete(callback: (data: ComparisonResult) => void): Comparison; | ||
| ignoreNothing(): ResembleComparison; | ||
| ignoreAntialiasing(): ResembleComparison; | ||
| ignoreColors(): ResembleComparison; | ||
| ignoreAlpha(): ResembleComparison; | ||
| ignoreLess(): ResembleComparison; | ||
| repaint(): ResembleComparison; | ||
| /** | ||
| * Set the resemblance image output style | ||
| */ | ||
| outputSettings(settings: OutputSettings): Comparison; | ||
| useOriginalSize(): ResembleComparison; | ||
| scaleToSameSize(): ResembleComparison; | ||
| /** | ||
| * Ignore nothing when comparing images | ||
| * | ||
| * This will disable ignoreAntialiasing and ignoreColors. | ||
| */ | ||
| ignoreNothing(): Comparison; | ||
| setReturnEarlyThreshold(threshold: number): ResembleComparison; | ||
| /** | ||
| * Ignore as less as possible when comparing images | ||
| * | ||
| * This will disable ignoreAntialiasing and ignoreColors. | ||
| */ | ||
| ignoreLess(): Comparison; | ||
| /** | ||
| * Ignore alpha channel when comparing images | ||
| * | ||
| * This will disable ignoreAntialiasing and ignoreColors. | ||
| */ | ||
| ignoreAlpha(): Comparison; | ||
| /** | ||
| * Ignore antialiasing when comparing images | ||
| * | ||
| * This will disable ignoreColors. | ||
| */ | ||
| ignoreAntialiasing(): Comparison; | ||
| /** | ||
| * Ignore colors when comparing images | ||
| * | ||
| * This will diable ignoreAntialiasing. | ||
| */ | ||
| ignoreColors(): Comparison; | ||
| /** | ||
| * Redo the comparison (with the new settings) | ||
| */ | ||
| repaint(): Comparison; | ||
| /** | ||
| * Use images' original size | ||
| */ | ||
| useOriginalSize(): Comparison; | ||
| /** | ||
| * Scale second image to dimensions of the first one | ||
| */ | ||
| scaleToSameSize(): Comparison; | ||
| setCustomTolerance(customSettings: Tolerance): void; | ||
| setReturnEarlyThreshold(threshold: number): Comparison; | ||
| } | ||
| interface ResembleComparisonResult { | ||
| interface ComparisonResult { | ||
| /** | ||
| * Error information if error encountered | ||
| * | ||
| * Note: If error encountered, other properties will be undefined | ||
| */ | ||
| error?: unknown | undefined; | ||
| /** | ||
| * Time consumed by the comparison (in milliseconds) | ||
| */ | ||
| analysisTime: number; | ||
| /** | ||
| * Do the two images have the same dimensions? | ||
@@ -99,2 +145,14 @@ */ | ||
| /** | ||
| * The percentage of pixels which do not match between the images | ||
| */ | ||
| rawMisMatchPercentage: number; | ||
| /** | ||
| * Same as `rawMisMatchPercentage` but fixed to 2-digit after the decimal point | ||
| */ | ||
| misMatchPercentage: number; | ||
| diffBounds: Box; | ||
| /** | ||
| * Get a data URL for the comparison image | ||
@@ -105,17 +163,28 @@ */ | ||
| /** | ||
| * The percentage of pixels which do not match between the images | ||
| * Get data buffer | ||
| */ | ||
| misMatchPercentage: string; | ||
| getBuffer?: (includeOriginal: boolean) => Buffer; | ||
| } | ||
| diffBounds: { | ||
| top: number; | ||
| left: number; | ||
| bottom: number; | ||
| right: number; | ||
| }; | ||
| analysisTime: number; | ||
| interface OutputSettings { | ||
| errorColor?: | ||
| | { | ||
| red: number; | ||
| green: number; | ||
| blue: number; | ||
| } | ||
| | undefined; | ||
| errorType?: OutputErrorType | undefined; | ||
| errorPixel?: ((px: number[], offset: number, d1: Color, d2: Color) => void) | undefined; | ||
| transparency?: number | undefined; | ||
| largeImageThreshold?: number | undefined; | ||
| useCrossOrigin?: boolean | undefined; | ||
| boundingBox?: Box | undefined; | ||
| ignoredBox?: Box | undefined; | ||
| boundingBoxes?: Box[] | undefined; | ||
| ignoredBoxes?: Box[] | undefined; | ||
| ignoreAreasColoredWith?: Color | undefined; | ||
| } | ||
| interface ResembleBox { | ||
| interface Box { | ||
| left: number; | ||
@@ -127,3 +196,3 @@ top: number; | ||
| interface ResembleColor { | ||
| interface Color { | ||
| r: number; | ||
@@ -135,25 +204,36 @@ g: number; | ||
| function compare( | ||
| image1: string | Buffer, | ||
| image2: string | Buffer, | ||
| options: ResembleSingleCallbackComparisonOptions, | ||
| callback: (err: unknown, data: ResembleSingleCallbackComparisonResult) => void, | ||
| ): void; | ||
| interface Tolerance { | ||
| red?: number; | ||
| green?: number; | ||
| blue?: number; | ||
| alpha?: number; | ||
| minBrightness?: number; | ||
| maxBrightness?: number; | ||
| } | ||
| function compareImages( | ||
| image1: string | Buffer, | ||
| image2: string | Buffer, | ||
| options: ResembleSingleCallbackComparisonOptions, | ||
| ): Promise<ResembleSingleCallbackComparisonResult>; | ||
| interface ResembleSingleCallbackComparisonOptions { | ||
| interface ComparisonOptions { | ||
| output?: OutputSettings | undefined; | ||
| returnEarlyThreshold?: number | undefined; | ||
| scaleToSameSize?: boolean | undefined; | ||
| ignore?: 'nothing' | 'less' | 'antialiasing' | 'colors' | 'alpha' | undefined; | ||
| ignore?: ComparisonIgnoreOption | ComparisonIgnoreOption[] | undefined; | ||
| tolerance?: Tolerance | undefined; | ||
| } | ||
| interface ResembleSingleCallbackComparisonResult extends ResembleComparisonResult { | ||
| getBuffer: () => Buffer; | ||
| } | ||
| type OutputErrorType = 'flat' | 'movement' | 'flatDifferenceIntensity' | 'movementDifferenceIntensity' | 'diffOnly'; | ||
| type ComparisonCallback = (err: unknown, data: ComparisonResult) => void; | ||
| type ComparisonIgnoreOption = 'nothing' | 'less' | 'antialiasing' | 'colors' | 'alpha'; | ||
| function compare( | ||
| image1: string | ImageData | Buffer, | ||
| image2: string | ImageData | Buffer, | ||
| options: ComparisonOptions | ComparisonCallback, | ||
| callback: ComparisonCallback, | ||
| ): void; | ||
| /** | ||
| * Set the resemblance image output style | ||
| */ | ||
| function outputSettings(settings: OutputSettings): typeof Resemble; | ||
| } |
| { | ||
| "name": "@types/resemblejs", | ||
| "version": "3.2.1", | ||
| "version": "4.1.0", | ||
| "description": "TypeScript definitions for Resemble.js", | ||
@@ -9,5 +9,5 @@ "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/resemblejs", | ||
| { | ||
| "name": "Tim Perry", | ||
| "url": "https://github.com/pimterry", | ||
| "githubUsername": "pimterry" | ||
| "name": "GreenYun", | ||
| "url": "https://github.com/Greenyun", | ||
| "githubUsername": "Greenyun" | ||
| } | ||
@@ -24,4 +24,4 @@ ], | ||
| "dependencies": {}, | ||
| "typesPublisherContentHash": "d1416199ff6eeda69885e52ce2fa32725ad4a31e4acf17586ac57ed78b133089", | ||
| "typeScriptVersion": "3.6" | ||
| "typesPublisherContentHash": "95af4b97645259f108fd7901f6ba8331413937df3d2aff68153448b86569618b", | ||
| "typeScriptVersion": "3.9" | ||
| } |
@@ -11,3 +11,3 @@ # Installation | ||
| ### Additional Details | ||
| * Last updated: Thu, 08 Jul 2021 22:42:01 GMT | ||
| * Last updated: Thu, 24 Mar 2022 05:31:41 GMT | ||
| * Dependencies: none | ||
@@ -17,2 +17,2 @@ * Global values: `resemble` | ||
| # Credits | ||
| These definitions were written by [Tim Perry](https://github.com/pimterry). | ||
| These definitions were written by [GreenYun](https://github.com/Greenyun). |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
9253
30.71%5
25%204
59.38%2
Infinity%1
Infinity%