You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
closes#53
This implements a pretty efficient way to accept buffers as an input by
receiving the buffer length as an input in the command and reading
excact amount of bytes
Copy file name to clipboardExpand all lines: README.md
+23-3Lines changed: 23 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -143,7 +143,7 @@ odiff --help
143
143
144
144
NodeJS Api is pretty tiny as well. Here is a typescript interface we have:
145
145
146
-
146
+
<!--inline-interface-start-->
147
147
```tsx
148
148
exporttypeODiffOptions=Partial<{
149
149
/** Color used to highlight different pixels in the output (in hex format e.g. #cd2cc9). */
@@ -220,7 +220,7 @@ declare function compare(
220
220
* server.stop();
221
221
* ```
222
222
*
223
-
* It is absolutely fine to keep odiff server living in the module root
223
+
* It is absolutely fine to keep odiff sever leaving in the module root
224
224
* even if you have several independent workers, it will automatically spawn
225
225
* a server process per each multiplexed core to work in parallel
226
226
*
@@ -261,6 +261,27 @@ export declare class ODiffServer {
261
261
options?:ODiffOptions& { timeout?:number },
262
262
):Promise<ODiffResult>;
263
263
264
+
/**
265
+
* Compare two images buffers, the buffer data is the actual encoded file bytes.
266
+
* **Important**: Always prefer file paths compare if you are saving images to disk anyway.
267
+
*
268
+
* @parambaseBuffer - Buffer containing base image data
269
+
* @parambaseFormat - Format of base image: "png", "jpeg", "jpg", "bmp", "tiff", "webp"
270
+
* @paramcompareBuffer - Buffer containing compare image data
271
+
* @paramcompareFormat - Format of compare image: "png", "jpeg", "jpg", "bmp", "tiff", "webp"
272
+
* @paramdiffOutput - Path to output diff image
273
+
* @paramoptions - Comparison options with optional timeout for request
274
+
* @returns Promise resolving to comparison result
275
+
*/
276
+
compareBuffers(
277
+
baseBuffer:Buffer,
278
+
baseFormat:string,
279
+
compareBuffer:Buffer,
280
+
compareFormat:string,
281
+
diffOutput:string,
282
+
options?:ODiffOptions& { timeout?:number },
283
+
):Promise<ODiffResult>;
284
+
264
285
/**
265
286
* Stop the odiff server process
266
287
* Should be called when done with all comparisons
@@ -271,7 +292,6 @@ export declare class ODiffServer {
271
292
272
293
export { compare, ODiffServer };
273
294
```
274
-
275
295
<!--inline-interface-end-->
276
296
277
297
Compare option will return `{ match: true }` if images are identical. Otherwise return `{ match: false, reason: "*" }` with a reason why images were different.
Compare option will return `{ match: true }` if images are identical. Otherwise return `{ match: false, reason: "*" }` with a reason why images were different.
278
279
279
280
> Make sure that diff output file will be created only if images have pixel difference we can see 👀
0 commit comments