Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@applitools/image

Package Overview
Dependencies
Maintainers
34
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@applitools/image - npm Package Compare versions

Comparing version 1.0.22 to 1.0.23

35

dist/image.js

@@ -39,3 +39,3 @@ "use strict";

let image, size;
let transforms = { rotate: 0, scale: 1, crop: null, modifiers: [] };
let transforms = { rotate: 0, scale: 1, crop: undefined, modifiers: [] };
if (utils.types.isBase64(data)) {

@@ -64,3 +64,3 @@ return makeImage(Buffer.from(data, 'base64'));

}
else if (data.isImage) {
else if (utils.types.has(data, 'isImage')) {
transforms = data.transforms;

@@ -72,3 +72,3 @@ image = data.toRaw();

image = fromSize(data);
if (utils.types.has(data, 'data'))
if (utils.types.has(data, 'data') && data.data)
image.data = data.data;

@@ -88,3 +88,4 @@ size = { width: data.width, height: data.height };

get size() {
const croppedSize = utils.geometry.size(transforms.crop || size);
var _a;
const croppedSize = utils.geometry.size((_a = transforms.crop) !== null && _a !== void 0 ? _a : size);
const scaledSize = utils.geometry.scale(croppedSize, transforms.scale);

@@ -95,3 +96,4 @@ const rotatedSize = utils.geometry.rotate(scaledSize, transforms.rotate);

get unscaledSize() {
const croppedSize = utils.geometry.size(transforms.crop || size);
var _a;
const croppedSize = utils.geometry.size((_a = transforms.crop) !== null && _a !== void 0 ? _a : size);
const rotatedSize = utils.geometry.rotate(croppedSize, transforms.rotate);

@@ -137,3 +139,3 @@ return utils.geometry.ceil(rotatedSize);

transforms.crop = region;
size = utils.geometry.size(transforms.crop);
size = utils.geometry.size(region);
return this;

@@ -193,3 +195,3 @@ },

size = { width: image.width, height: image.height };
transforms = { crop: null, scale: 1, rotate: 0, modifiers: [] };
transforms = { crop: undefined, scale: 1, rotate: 0, modifiers: [] };
return image;

@@ -203,3 +205,3 @@ },

const transformedImage = await transform(image ? await image : size, transforms);
return toFile(transformedImage, path_1.default.join(debug.path, filename)).catch(() => null);
return toFile(transformedImage, path_1.default.join(debug.path, filename)).catch(() => undefined);
},

@@ -236,2 +238,3 @@ };

}
return { width: 0, height: 0 };
}

@@ -286,7 +289,11 @@ function extractBmpSize(buffer) {

}
async function transform(image, transforms) {
if (!image.data) {
async function transform(imageOrSize, transforms) {
let image;
if (utils.types.has(imageOrSize, 'data')) {
image = imageOrSize;
}
else {
const size = transforms.added
? { width: image.width - transforms.added.width, height: image.height - transforms.added.height }
: image;
? { width: imageOrSize.width - transforms.added.width, height: imageOrSize.height - transforms.added.height }
: imageOrSize;
image = new png.Image(size);

@@ -304,3 +311,3 @@ }

}
}, image);
}, Promise.resolve(image));
image = transforms.crop ? await extract(image, transforms.crop) : image;

@@ -394,3 +401,3 @@ image = transforms.scale !== 1 ? await scale(image, transforms.scale) : image;

else {
return dstImage.data.set(image.data);
dstImage.data.set(image.data);
}

@@ -397,0 +404,0 @@ return dstImage;

24

package.json
{
"name": "@applitools/image",
"version": "1.0.22",
"version": "1.0.23",
"description": "Image primitive used for capturing and manipulating screenshots",

@@ -37,8 +37,8 @@ "homepage": "https://applitools.com",

"scripts": {
"lint": "eslint '**/*.ts'",
"build": "tsc",
"lint": "npx eslint '**/*.ts'",
"build": "npx tsc --project ./tsconfig.build.json",
"test": "mocha --no-timeouts -r ts-node/register 'test/*.spec.ts'",
"test:sanity": "yarn test",
"deps": "bongo deps",
"preversion": "bongo preversion && yarn build",
"preversion": "bongo preversion",
"version": "bongo version",

@@ -48,3 +48,3 @@ "postversion": "bongo postversion --skip-release-notification"

"dependencies": {
"@applitools/utils": "1.3.28",
"@applitools/utils": "1.3.29",
"bmpimagejs": "1.0.4",

@@ -56,19 +56,7 @@ "jpeg-js": "0.4.4",

"@applitools/bongo": "^2.2.2",
"@applitools/scripts": "^1.2.0",
"@types/bmp-js": "^0.1.0",
"@types/mocha": "^9.1.1",
"@types/node": "12",
"@types/pixelmatch": "^5.2.4",
"@typescript-eslint/eslint-plugin": "^4.7.0",
"@typescript-eslint/parser": "^4.7.0",
"eslint": "^7.25.0",
"eslint-config-prettier": "^6.15.0",
"eslint-plugin-mocha-no-only": "^1.1.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^3.1.4",
"mocha": "^10.0.0",
"pixelmatch": "^5.3.0",
"prettier": "^2.7.1",
"ts-node": "^10.2.1",
"typescript": "^4.8.4"
"pixelmatch": "^5.3.0"
},

@@ -75,0 +63,0 @@ "engines": {

/// <reference types="node" />
declare type TransformData = {
rotate: number;
scale: number;
crop?: any;
modifiers: any[];
added?: any;
};
import type { Location, Size, Region } from '@applitools/utils';
export interface Image {
isImage: boolean;
size: {
width: number;
height: number;
};
unscaledSize: {
width?: number;
height?: number;
x?: number;
y?: number;
};
rawSize: {
width: number;
height: number;
};
transforms: TransformData;
isImage: true;
size: Size;
unscaledSize: Size;
rawSize: Size;
transforms: Transforms;
width: number;

@@ -33,10 +16,36 @@ height: number;

frame(topImage: Image, bottomImage: Image, region: any): Image;
toRaw(): Promise<any>;
toRaw(): Promise<ImageRaw>;
toBuffer(): Promise<Buffer>;
toPng(): Promise<any>;
toFile(path: string): Promise<any>;
toObject(): Promise<any>;
debug(debug: any): Promise<any>;
toPng(): Promise<Buffer>;
toFile(path: string): Promise<void>;
toObject(): Promise<ImageRaw>;
debug(debug: any): Promise<void>;
}
export declare function makeImage(data: any): Image;
type ImageSource = string | Buffer | Image | (Size & {
data?: Buffer;
}) | {
auto: true;
};
type ImageRaw = {
width: number;
height: number;
data: Buffer;
};
type Transforms = {
rotate: number;
scale: number;
crop?: Region;
modifiers: ({
type: 'copy';
image: Promise<ImageRaw>;
offset: Location;
} | {
type: 'frame';
top: Promise<ImageRaw>;
bottom: Promise<ImageRaw>;
region: Region;
})[];
added?: any;
};
export declare function makeImage(data: ImageSource): Image;
export {};
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc