@appium/images-plugin 2.0.10 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,96 +3,61 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.DEFAULT_FIX_IMAGE_TEMPLATE_SCALE = exports.DEFAULT_SETTINGS = exports.MJSONWP_ELEMENT_KEY = exports.W3C_ELEMENT_KEY = void 0;
7
6
  const lodash_1 = __importDefault(require("lodash"));
8
7
  const lru_cache_1 = __importDefault(require("lru-cache"));
9
8
  const driver_1 = require("appium/driver");
10
- const support_1 = require("appium/support");
11
9
  const image_element_1 = require("./image-element");
12
10
  const compare_1 = require("./compare");
13
11
  const logger_1 = __importDefault(require("./logger"));
14
- const MJSONWP_ELEMENT_KEY = 'ELEMENT';
15
- exports.MJSONWP_ELEMENT_KEY = MJSONWP_ELEMENT_KEY;
16
- const W3C_ELEMENT_KEY = support_1.util.W3C_WEB_ELEMENT_IDENTIFIER;
17
- exports.W3C_ELEMENT_KEY = W3C_ELEMENT_KEY;
18
- const DEFAULT_FIX_IMAGE_TEMPLATE_SCALE = 1;
19
- exports.DEFAULT_FIX_IMAGE_TEMPLATE_SCALE = DEFAULT_FIX_IMAGE_TEMPLATE_SCALE;
12
+ const constants_1 = require("./constants");
13
+ const sharp_1 = __importDefault(require("sharp"));
20
14
  // Used to compare ratio and screen width
21
15
  // Pixel is basically under 1080 for example. 100K is probably enough fo a while.
22
16
  const FLOAT_PRECISION = 100000;
23
17
  const MAX_CACHE_ITEMS = 100;
24
- const MAX_CACHE_SIZE_BYTES = 1024 * 1024 * 40; // 40mb
25
- const DEFAULT_SETTINGS = {
26
- // value between 0 and 1 representing match strength, below which an image
27
- // element will not be found
28
- imageMatchThreshold: compare_1.DEFAULT_MATCH_THRESHOLD,
29
- // One of possible image matching methods.
30
- // Read https://docs.opencv.org/3.0-beta/doc/py_tutorials/py_imgproc/py_template_matching/py_template_matching.html
31
- // for more details.
32
- // TM_CCOEFF_NORMED by default
33
- imageMatchMethod: '',
34
- // if the image returned by getScreenshot differs in size or aspect ratio
35
- // from the screen, attempt to fix it automatically
36
- fixImageFindScreenshotDims: true,
37
- // whether Appium should ensure that an image template sent in during image
38
- // element find should have its size adjusted so the match algorithm will not
39
- // complain
40
- fixImageTemplateSize: false,
41
- // whether Appium should ensure that an image template sent in during image
42
- // element find should have its scale adjusted to display size so the match
43
- // algorithm will not complain.
44
- // e.g. iOS has `width=375, height=667` window rect, but its screenshot is
45
- // `width=750 × height=1334` pixels. This setting help to adjust the scale
46
- // if a user use `width=750 × height=1334` pixels's base template image.
47
- fixImageTemplateScale: false,
48
- // Users might have scaled template image to reduce their storage size.
49
- // This setting allows users to scale a template image they send to Appium server
50
- // so that the Appium server compares the actual scale users originally had.
51
- // e.g. If a user has an image of 270 x 32 pixels which was originally 1080 x 126 pixels,
52
- // the user can set {defaultImageTemplateScale: 4.0} to scale the small image
53
- // to the original one so that Appium can compare it as the original one.
54
- defaultImageTemplateScale: image_element_1.DEFAULT_TEMPLATE_IMAGE_SCALE,
55
- // whether Appium should re-check that an image element can be matched
56
- // against the current screenshot before clicking it
57
- checkForImageElementStaleness: true,
58
- // whether before clicking on an image element Appium should re-determine the
59
- // position of the element on screen
60
- autoUpdateImageElementPosition: false,
61
- // which method to use for tapping by coordinate for image elements. the
62
- // options are 'w3c' or 'mjsonwp'
63
- imageElementTapStrategy: image_element_1.IMAGE_EL_TAP_STRATEGY_W3C,
64
- // which method to use to save the matched image area in ImageElement class.
65
- // It is used for debugging purpose.
66
- getMatchedImageResult: false,
67
- };
68
- exports.DEFAULT_SETTINGS = DEFAULT_SETTINGS;
18
+ const MAX_CACHE_AGE_MS = 24 * 60 * 60 * 1000;
19
+ /**
20
+ * Checks if one rect fully contains another
21
+ *
22
+ * @param {import('@appium/types').Rect} templateRect The bounding rect
23
+ * @param {import('@appium/types').Rect} rect The rect to be checked for containment
24
+ * @returns {boolean} True if templateRect contains rect
25
+ */
26
+ function containsRect(templateRect, rect) {
27
+ return templateRect.x <= rect.x && templateRect.y <= rect.y
28
+ && rect.width <= templateRect.x + templateRect.width - rect.x
29
+ && rect.height <= templateRect.y + templateRect.height - rect.y;
30
+ }
69
31
  const NO_OCCURRENCES_PATTERN = /Cannot find any occurrences/;
70
32
  const CONDITION_UNMET_PATTERN = /Condition unmet/;
71
33
  class ImageElementFinder {
72
34
  /**
73
- *
74
- * @param {ExternalDriver} driver
75
- * @param {number} [maxSize]
35
+ * @param {number} max
76
36
  */
77
- constructor(driver, maxSize = MAX_CACHE_SIZE_BYTES) {
78
- this.driver = driver;
79
- this.imgElCache = new lru_cache_1.default({
80
- max: MAX_CACHE_ITEMS,
81
- maxSize,
82
- sizeCalculation: (el) => el.template.length,
37
+ constructor(max = MAX_CACHE_ITEMS) {
38
+ this._imgElCache = new lru_cache_1.default({
39
+ ttl: MAX_CACHE_AGE_MS,
40
+ updateAgeOnGet: true,
41
+ max,
83
42
  });
84
43
  }
85
- setDriver(driver) {
86
- this.driver = driver;
87
- }
88
44
  /**
89
45
  * @param {ImageElement} imgEl
90
46
  * @returns {Element}
91
47
  */
92
48
  registerImageElement(imgEl) {
93
- this.imgElCache.set(imgEl.id, imgEl);
94
- const protoKey = this.driver.isW3CProtocol() ? W3C_ELEMENT_KEY : MJSONWP_ELEMENT_KEY;
95
- return imgEl.asElement(protoKey);
49
+ this._imgElCache.set(imgEl.id, imgEl);
50
+ return imgEl.asElement();
51
+ }
52
+ /**
53
+ * @param {string} imgElId
54
+ * @returns {ImageElement|undefined}
55
+ */
56
+ getImageElement(imgElId) {
57
+ return this._imgElCache.get(imgElId);
58
+ }
59
+ clearImageElements() {
60
+ this._imgElCache.clear();
96
61
  }
97
62
  /**
98
63
  * @typedef FindByImageOptions
@@ -102,41 +67,55 @@ class ImageElementFinder {
102
67
  * multiple
103
68
  * @property {boolean} [ignoreDefaultImageTemplateScale=false] - Whether we
104
69
  * ignore defaultImageTemplateScale. It can be used when you would like to
105
- * scale b64Template with defaultImageTemplateScale setting.
70
+ * scale template with defaultImageTemplateScale setting.
71
+ * @property {import('@appium/types').Rect?} containerRect - The bounding
72
+ * rectangle to limit the search in
106
73
  */
107
74
  /**
108
75
  * Find a screen rect represented by an ImageElement corresponding to an image
109
76
  * template sent in by the client
110
77
  *
111
- * @param {string} b64Template - base64-encoded image used as a template to be
78
+ * @param {Buffer} template - image used as a template to be
112
79
  * matched in the screenshot
80
+ * @param {ExternalDriver} driver
113
81
  * @param {FindByImageOptions} opts - additional options
114
82
  *
115
83
  * @returns {Promise<Element|Element[]|ImageElement>} - WebDriver element with a special id prefix
116
84
  */
117
- async findByImage(b64Template, { shouldCheckStaleness = false, multiple = false, ignoreDefaultImageTemplateScale = false }) {
118
- if (!this.driver) {
119
- throw new Error(`Can't find without a driver!`);
120
- }
121
- const settings = { ...DEFAULT_SETTINGS, ...this.driver.settings.getSettings() };
85
+ async findByImage(template, driver, { shouldCheckStaleness = false, multiple = false, ignoreDefaultImageTemplateScale = false, containerRect = null }) {
86
+ const settings = { ...constants_1.DEFAULT_SETTINGS, ...driver.settings.getSettings() };
122
87
  const { imageMatchThreshold: threshold, imageMatchMethod, fixImageTemplateSize, fixImageTemplateScale, defaultImageTemplateScale, getMatchedImageResult: visualize, } = settings;
123
88
  logger_1.default.info(`Finding image element with match threshold ${threshold}`);
124
- if (!this.driver.getWindowSize) {
125
- throw new Error("This driver does not support the required 'getWindowSize' command");
89
+ if (!driver.getWindowRect && !driver.getWindowSize) {
90
+ throw new Error("This driver does not support the required 'getWindowRect' command");
91
+ }
92
+ let screenSize;
93
+ if (driver.getWindowRect) {
94
+ const screenRect = await driver.getWindowRect();
95
+ screenSize = {
96
+ width: screenRect.width,
97
+ height: screenRect.height,
98
+ };
99
+ }
100
+ else {
101
+ // TODO: Drop the deprecated endpoint
102
+ screenSize = await driver.getWindowSize();
126
103
  }
127
- const { width: screenWidth, height: screenHeight } = await this.driver.getWindowSize();
128
104
  // someone might have sent in a template that's larger than the screen
129
105
  // dimensions. If so let's check and cut it down to size since the algorithm
130
106
  // will not work unless we do. But because it requires some potentially
131
107
  // expensive commands, only do this if the user has requested it in settings.
132
108
  if (fixImageTemplateSize) {
133
- b64Template = await this.ensureTemplateSize(b64Template, screenWidth, screenHeight);
109
+ template = await this.ensureTemplateSize(template, {
110
+ width: containerRect ? containerRect.width : screenSize.width,
111
+ height: containerRect ? containerRect.height : screenSize.height,
112
+ });
134
113
  }
135
114
  const results = [];
136
115
  const condition = async () => {
137
116
  try {
138
- const { b64Screenshot, scale } = await this.getScreenshotForImageFind(screenWidth, screenHeight);
139
- b64Template = await this.fixImageTemplateScale(b64Template, {
117
+ const { screenshot, scale } = await this.getScreenshotForImageFind(driver, screenSize);
118
+ template = await this.fixImageTemplateScale(template, {
140
119
  defaultImageTemplateScale,
141
120
  ignoreDefaultImageTemplateScale,
142
121
  fixImageTemplateScale,
@@ -150,13 +129,17 @@ class ImageElementFinder {
150
129
  if (imageMatchMethod) {
151
130
  comparisonOpts.method = imageMatchMethod;
152
131
  }
153
- if (multiple) {
154
- results.push(...(await (0, compare_1.compareImages)(compare_1.MATCH_TEMPLATE_MODE, b64Screenshot, b64Template, comparisonOpts)));
155
- }
156
- else {
157
- results.push(await (0, compare_1.compareImages)(compare_1.MATCH_TEMPLATE_MODE, b64Screenshot, b64Template, comparisonOpts));
158
- }
159
- return true;
132
+ const pushIfOk = (el) => {
133
+ if (containerRect && !containsRect(containerRect, el.rect)) {
134
+ logger_1.default.debug(`The matched element rectangle ${JSON.stringify(el.rect)} is not located ` +
135
+ `inside of the bounding rectangle ${JSON.stringify(containerRect)}, thus rejected`);
136
+ return false;
137
+ }
138
+ results.push(el);
139
+ return true;
140
+ };
141
+ const elOrEls = await (0, compare_1.compareImages)(constants_1.MATCH_TEMPLATE_MODE, screenshot, template, comparisonOpts);
142
+ return lodash_1.default.some((lodash_1.default.isArray(elOrEls) ? elOrEls : [elOrEls]).map(pushIfOk));
160
143
  }
161
144
  catch (err) {
162
145
  // if compareImages fails, we'll get a specific error, but we should
@@ -170,7 +153,7 @@ class ImageElementFinder {
170
153
  }
171
154
  };
172
155
  try {
173
- await this.driver.implicitWaitForCondition(condition);
156
+ await driver.implicitWaitForCondition(condition);
174
157
  }
175
158
  catch (err) {
176
159
  // this `implicitWaitForCondition` method will throw a 'Condition unmet'
@@ -191,7 +174,14 @@ class ImageElementFinder {
191
174
  }
192
175
  const elements = results.map(({ rect, score, visualization }) => {
193
176
  logger_1.default.info(`Image template matched: ${JSON.stringify(rect)}`);
194
- return new image_element_1.ImageElement(b64Template, rect, score, visualization, this);
177
+ return new image_element_1.ImageElement({
178
+ template,
179
+ rect,
180
+ score,
181
+ match: visualization ? Buffer.from(visualization, 'base64') : null,
182
+ finder: this,
183
+ containerRect,
184
+ });
195
185
  });
196
186
  // if we're just checking staleness, return straightaway so we don't add
197
187
  // a new element to the cache. shouldCheckStaleness does not support multiple
@@ -205,68 +195,72 @@ class ImageElementFinder {
205
195
  /**
206
196
  * Ensure that the image template sent in for a find is of a suitable size
207
197
  *
208
- * @param {string} b64Template - base64-encoded image
209
- * @param {number} screenWidth - width of screen
210
- * @param {number} screenHeight - height of screen
198
+ * @param {Buffer} template - template image
199
+ * @param {import('@appium/types').Size} maxSize - size of the bounding rectangle
211
200
  *
212
- * @returns {Promise<string>} base64-encoded image, potentially resized
201
+ * @returns {Promise<Buffer>} image, potentially resized
213
202
  */
214
- async ensureTemplateSize(b64Template, screenWidth, screenHeight) {
215
- let imgObj = await support_1.imageUtil.getJimpImage(b64Template);
216
- let { width: tplWidth, height: tplHeight } = imgObj.bitmap;
217
- logger_1.default.info(`Template image is ${tplWidth}x${tplHeight}. Screen size is ${screenWidth}x${screenHeight}`);
203
+ async ensureTemplateSize(template, maxSize) {
204
+ const imgObj = (0, sharp_1.default)(template);
205
+ const { width: tplWidth, height: tplHeight } = await imgObj.metadata();
206
+ logger_1.default.info(`Template image is ${tplWidth}x${tplHeight}. Bounding rectangle size is ${maxSize.width}x${maxSize.height}`);
218
207
  // if the template fits inside the screen dimensions, we're good
219
- if (tplWidth <= screenWidth && tplHeight <= screenHeight) {
220
- return b64Template;
208
+ if (tplWidth <= maxSize.width && tplHeight <= maxSize.height) {
209
+ return template;
221
210
  }
222
211
  logger_1.default.info(`Scaling template image from ${tplWidth}x${tplHeight} to match ` +
223
- `screen at ${screenWidth}x${screenHeight}`);
224
- // otherwise, scale it to fit inside the screen dimensions
225
- imgObj = imgObj.scaleToFit(screenWidth, screenHeight);
226
- return (await imgObj.getBuffer(support_1.imageUtil.MIME_PNG)).toString('base64');
212
+ `the bounding rectangle at ${maxSize.width}x${maxSize.height}`);
213
+ // otherwise, scale it to fit inside the bounding rectangle dimensions:
214
+ // https://sharp.pixelplumbing.com/api-resize
215
+ return await imgObj.resize({
216
+ width: parseInt(maxSize.width, 10),
217
+ height: parseInt(maxSize.height, 10),
218
+ fit: 'inside',
219
+ })
220
+ .toBuffer();
227
221
  }
228
222
  /**
229
223
  * Get the screenshot image that will be used for find by element, potentially
230
224
  * altering it in various ways based on user-requested settings
231
225
  *
232
- * @param {number} screenWidth - width of screen
233
- * @param {number} screenHeight - height of screen
226
+ * @param {ExternalDriver} driver
227
+ * @param {import('@appium/types').Size} screenSize - The original size of the screen
234
228
  *
235
- * @returns {Promise<Screenshot & {scale?: ScreenshotScale}>} base64-encoded screenshot and ScreenshotScale
229
+ * @returns {Promise<Screenshot & {scale?: ScreenshotScale}>} PNG screenshot and ScreenshotScale
236
230
  */
237
- async getScreenshotForImageFind(screenWidth, screenHeight) {
238
- if (!this.driver.getScreenshot) {
231
+ async getScreenshotForImageFind(driver, screenSize) {
232
+ if (!driver.getScreenshot) {
239
233
  throw new Error("This driver does not support the required 'getScreenshot' command");
240
234
  }
241
- const settings = Object.assign({}, DEFAULT_SETTINGS, this.driver.settings.getSettings());
235
+ const settings = Object.assign({}, constants_1.DEFAULT_SETTINGS, driver.settings.getSettings());
242
236
  const { fixImageFindScreenshotDims } = settings;
243
- let b64Screenshot = await this.driver.getScreenshot();
237
+ const screenshot = Buffer.from(await driver.getScreenshot(), 'base64');
244
238
  // if the user has requested not to correct for aspect or size differences
245
239
  // between the screenshot and the screen, just return the screenshot now
246
240
  if (!fixImageFindScreenshotDims) {
247
241
  logger_1.default.info(`Not verifying screenshot dimensions match screen`);
248
- return { b64Screenshot };
242
+ return { screenshot };
249
243
  }
250
- if (screenWidth < 1 || screenHeight < 1) {
251
- logger_1.default.warn(`The retrieved screen size ${screenWidth}x${screenHeight} does ` +
244
+ if (screenSize.width < 1 || screenSize.height < 1) {
245
+ logger_1.default.warn(`The retrieved screen size ${screenSize.width}x${screenSize.height} does ` +
252
246
  `not seem to be valid. No changes will be applied to the screenshot`);
253
- return { b64Screenshot };
247
+ return { screenshot };
254
248
  }
255
249
  // otherwise, do some verification on the screenshot to make sure it matches
256
250
  // the screen size and aspect ratio
257
251
  logger_1.default.info('Verifying screenshot size and aspect ratio');
258
- let imgObj = await support_1.imageUtil.getJimpImage(b64Screenshot);
259
- let { width: shotWidth, height: shotHeight } = imgObj.bitmap;
252
+ let imgObj = (0, sharp_1.default)(screenshot);
253
+ let { width: shotWidth, height: shotHeight } = await imgObj.metadata();
260
254
  if (shotWidth < 1 || shotHeight < 1) {
261
255
  logger_1.default.warn(`The retrieved screenshot size ${shotWidth}x${shotHeight} does ` +
262
256
  `not seem to be valid. No changes will be applied to the screenshot`);
263
- return { b64Screenshot };
257
+ return { screenshot };
264
258
  }
265
- if (screenWidth === shotWidth && screenHeight === shotHeight) {
259
+ if (screenSize.width === shotWidth && screenSize.height === shotHeight) {
266
260
  // the height and width of the screenshot and the device screen match, which
267
261
  // means we should be safe when doing template matches
268
262
  logger_1.default.info('Screenshot size matched screen size');
269
- return { b64Screenshot };
263
+ return { screenshot };
270
264
  }
271
265
  // otherwise, if they don't match, it could spell problems for the accuracy
272
266
  // of coordinates returned by the image match algorithm, since we match based
@@ -274,16 +268,16 @@ class ImageElementFinder {
274
268
  // are two potential types of mismatch: aspect ratio mismatch and scale
275
269
  // mismatch. We need to detect and fix both
276
270
  const scale = { xScale: 1.0, yScale: 1.0 };
277
- const screenAR = screenWidth / screenHeight;
271
+ const screenAR = screenSize.width / screenSize.height;
278
272
  const shotAR = shotWidth / shotHeight;
279
273
  if (Math.round(screenAR * FLOAT_PRECISION) === Math.round(shotAR * FLOAT_PRECISION)) {
280
274
  logger_1.default.info(`Screenshot aspect ratio '${shotAR}' (${shotWidth}x${shotHeight}) matched ` +
281
- `screen aspect ratio '${screenAR}' (${screenWidth}x${screenHeight})`);
275
+ `screen aspect ratio '${screenAR}' (${screenSize.width}x${screenSize.height})`);
282
276
  }
283
277
  else {
284
278
  logger_1.default.warn(`When trying to find an element, determined that the screen ` +
285
279
  `aspect ratio and screenshot aspect ratio are different. Screen ` +
286
- `is ${screenWidth}x${screenHeight} whereas screenshot is ` +
280
+ `is ${screenSize.width}x${screenSize.height} whereas screenshot is ` +
287
281
  `${shotWidth}x${shotHeight}.`);
288
282
  // In the case where the x-scale and y-scale are different, we need to decide
289
283
  // which one to respect, otherwise the screenshot and template will end up
@@ -291,43 +285,54 @@ class ImageElementFinder {
291
285
  // this.getScreenshot(shotWidth, shotHeight) is 540x397,
292
286
  // this.getDeviceSize(screenWidth, screenHeight) is 1080x1920.
293
287
  // The ratio would then be {xScale: 0.5, yScale: 0.2}.
294
- // In this case, we must should `yScale: 0.2` as scaleFactor, because
288
+ // In this case, we must use `yScale: 0.2` as scaleFactor, because
295
289
  // if we select the xScale, the height will be bigger than real screenshot size
296
290
  // which is used to image comparison by OpenCV as a base image.
297
291
  // All of this is primarily useful when the screenshot is a horizontal slice taken out of the
298
292
  // screen (for example not including top/bottom nav bars)
299
- const xScale = (1.0 * shotWidth) / screenWidth;
300
- const yScale = (1.0 * shotHeight) / screenHeight;
301
- const scaleFactor = xScale >= yScale ? yScale : xScale;
302
- logger_1.default.warn(`Resizing screenshot to ${shotWidth * scaleFactor}x${shotHeight * scaleFactor} to match ` +
293
+ const xScale = (1.0 * shotWidth) / screenSize.width;
294
+ const yScale = (1.0 * shotHeight) / screenSize.height;
295
+ const scaleFactor = Math.min(xScale, yScale);
296
+ const [newWidth, newHeight] = [shotWidth * scaleFactor, shotHeight * scaleFactor]
297
+ .map((x) => parseInt(x, 10));
298
+ logger_1.default.warn(`Resizing screenshot to ${newWidth}x${newHeight} to match ` +
303
299
  `screen aspect ratio so that image element coordinates have a ` +
304
300
  `greater chance of being correct.`);
305
- imgObj = imgObj.resize(shotWidth * scaleFactor, shotHeight * scaleFactor);
301
+ imgObj = imgObj.resize({
302
+ width: newWidth,
303
+ height: newHeight,
304
+ fit: 'fill',
305
+ });
306
306
  scale.xScale *= scaleFactor;
307
307
  scale.yScale *= scaleFactor;
308
- shotWidth = imgObj.bitmap.width;
309
- shotHeight = imgObj.bitmap.height;
308
+ [shotWidth, shotHeight] = [newWidth, newHeight];
310
309
  }
311
310
  // Resize based on the screen dimensions only if both width and height are mismatched
312
311
  // since except for that, it might be a situation which is different window rect and
313
312
  // screenshot size like `@driver.window_rect #=>x=0, y=0, width=1080, height=1794` and
314
313
  // `"deviceScreenSize"=>"1080x1920"`
315
- if (screenWidth !== shotWidth && screenHeight !== shotHeight) {
314
+ if (screenSize.width !== shotWidth && screenSize.height !== shotHeight) {
316
315
  logger_1.default.info(`Scaling screenshot from ${shotWidth}x${shotHeight} to match ` +
317
- `screen at ${screenWidth}x${screenHeight}`);
318
- imgObj = imgObj.resize(screenWidth, screenHeight);
319
- scale.xScale *= (1.0 * screenWidth) / shotWidth;
320
- scale.yScale *= (1.0 * screenHeight) / shotHeight;
316
+ `screen at ${screenSize.width}x${screenSize.height}`);
317
+ imgObj = imgObj.resize({
318
+ width: parseInt(screenSize.width, 10),
319
+ height: parseInt(screenSize.height, 10),
320
+ fit: 'fill',
321
+ });
322
+ scale.xScale *= (1.0 * screenSize.width) / shotWidth;
323
+ scale.yScale *= (1.0 * screenSize.height) / shotHeight;
321
324
  }
322
- b64Screenshot = (await imgObj.getBuffer(support_1.imageUtil.MIME_PNG)).toString('base64');
323
- return { b64Screenshot, scale };
325
+ return {
326
+ screenshot: await imgObj.toBuffer(),
327
+ scale,
328
+ };
324
329
  }
325
330
  /**
326
331
  * @typedef ImageTemplateSettings
327
332
  * @property {boolean} fixImageTemplateScale - fixImageTemplateScale in device-settings
328
333
  * @property {number} defaultImageTemplateScale - defaultImageTemplateScale in device-settings
329
334
  * @property {boolean} ignoreDefaultImageTemplateScale - Ignore defaultImageTemplateScale if it has true.
330
- * If b64Template has been scaled to defaultImageTemplateScale or should ignore the scale,
335
+ * If the template has been scaled to defaultImageTemplateScale or should ignore the scale,
331
336
  * this parameter should be true. e.g. click in image-element module
332
337
  * @property {number} xScale - Scale ratio for width
333
338
  * @property {number} yScale - Scale ratio for height
@@ -337,27 +342,26 @@ class ImageElementFinder {
337
342
  * Get a image that will be used for template maching.
338
343
  * Returns scaled image if scale ratio is provided.
339
344
  *
340
- *
341
- * @param {string} b64Template - base64-encoded image used as a template to be
345
+ * @param {Buffer} template - image used as a template to be
342
346
  * matched in the screenshot
343
347
  * @param {ImageTemplateSettings} opts - Image template scale related options
344
348
  *
345
- * @returns {Promise<string>} base64-encoded scaled template screenshot
349
+ * @returns {Promise<Buffer>} scaled template screenshot
346
350
  */
347
- async fixImageTemplateScale(b64Template, opts) {
351
+ async fixImageTemplateScale(template, opts) {
348
352
  if (!opts) {
349
- return b64Template;
353
+ return template;
350
354
  }
351
- let { fixImageTemplateScale = false, defaultImageTemplateScale = image_element_1.DEFAULT_TEMPLATE_IMAGE_SCALE, ignoreDefaultImageTemplateScale = false, xScale = DEFAULT_FIX_IMAGE_TEMPLATE_SCALE, yScale = DEFAULT_FIX_IMAGE_TEMPLATE_SCALE, } = opts;
355
+ let { fixImageTemplateScale: fixTplScale = false, defaultImageTemplateScale = constants_1.DEFAULT_TEMPLATE_IMAGE_SCALE, ignoreDefaultImageTemplateScale = false, xScale = constants_1.DEFAULT_FIX_IMAGE_TEMPLATE_SCALE, yScale = constants_1.DEFAULT_FIX_IMAGE_TEMPLATE_SCALE, } = opts;
352
356
  if (ignoreDefaultImageTemplateScale) {
353
- defaultImageTemplateScale = image_element_1.DEFAULT_TEMPLATE_IMAGE_SCALE;
357
+ defaultImageTemplateScale = constants_1.DEFAULT_TEMPLATE_IMAGE_SCALE;
354
358
  }
355
359
  // Default
356
- if (defaultImageTemplateScale === image_element_1.DEFAULT_TEMPLATE_IMAGE_SCALE && !fixImageTemplateScale) {
357
- return b64Template;
360
+ if (defaultImageTemplateScale === constants_1.DEFAULT_TEMPLATE_IMAGE_SCALE && !fixTplScale) {
361
+ return template;
358
362
  }
359
363
  // Calculate xScale and yScale Appium should scale
360
- if (fixImageTemplateScale) {
364
+ if (fixTplScale) {
361
365
  xScale *= defaultImageTemplateScale;
362
366
  yScale *= defaultImageTemplateScale;
363
367
  }
@@ -366,24 +370,27 @@ class ImageElementFinder {
366
370
  }
367
371
  // xScale and yScale can be NaN if defaultImageTemplateScale is string, for example
368
372
  if (!parseFloat(String(xScale)) || !parseFloat(String(yScale))) {
369
- return b64Template;
373
+ return template;
370
374
  }
371
375
  // Return if the scale is default, 1, value
372
376
  if (Math.round(xScale * FLOAT_PRECISION) ===
373
- Math.round(DEFAULT_FIX_IMAGE_TEMPLATE_SCALE * FLOAT_PRECISION) &&
377
+ Math.round(constants_1.DEFAULT_FIX_IMAGE_TEMPLATE_SCALE * FLOAT_PRECISION) &&
374
378
  Math.round(Number(yScale * FLOAT_PRECISION ===
375
- Math.round(DEFAULT_FIX_IMAGE_TEMPLATE_SCALE * FLOAT_PRECISION)))) {
376
- return b64Template;
379
+ Math.round(constants_1.DEFAULT_FIX_IMAGE_TEMPLATE_SCALE * FLOAT_PRECISION)))) {
380
+ return template;
377
381
  }
378
- let imgTempObj = await support_1.imageUtil.getJimpImage(b64Template);
379
- let { width: baseTempWidth, height: baseTempHeigh } = imgTempObj.bitmap;
382
+ let imgObj = (0, sharp_1.default)(template);
383
+ const { width: baseTempWidth, height: baseTempHeigh } = await imgObj.metadata();
380
384
  const scaledWidth = baseTempWidth * xScale;
381
385
  const scaledHeight = baseTempHeigh * yScale;
382
- logger_1.default.info(`Scaling template image from ${baseTempWidth}x${baseTempHeigh}` +
383
- ` to ${scaledWidth}x${scaledHeight}`);
386
+ logger_1.default.info(`Scaling template image from ${baseTempWidth}x${baseTempHeigh} to ${scaledWidth}x${scaledHeight}`);
384
387
  logger_1.default.info(`The ratio is ${xScale} and ${yScale}`);
385
- imgTempObj = await imgTempObj.resize(scaledWidth, scaledHeight);
386
- return (await imgTempObj.getBuffer(support_1.imageUtil.MIME_PNG)).toString('base64');
388
+ imgObj = imgObj.resize({
389
+ width: parseInt(scaledWidth, 10),
390
+ height: parseInt(scaledHeight, 10),
391
+ fit: 'fill',
392
+ });
393
+ return await imgObj.toBuffer();
387
394
  }
388
395
  }
389
396
  exports.default = ImageElementFinder;
@@ -393,7 +400,7 @@ exports.default = ImageElementFinder;
393
400
  */
394
401
  /**
395
402
  * @typedef Screenshot
396
- * @property {string} b64Screenshot - base64 based screenshot string
403
+ * @property {Buffer} screenshot - screenshot image as PNG
397
404
  */
398
405
  /**
399
406
  * @typedef ScreenshotScale
@@ -1 +1 @@
1
- {"version":3,"file":"finder.js","sourceRoot":"","sources":["../../lib/finder.js"],"names":[],"mappings":";;;;;;AAAA,oDAAuB;AACvB,0DAA4B;AAC5B,0CAAqC;AACrC,4CAA+C;AAC/C,mDAIyB;AACzB,uCAAsF;AACtF,sDAA2B;AAE3B,MAAM,mBAAmB,GAAG,SAAS,CAAC;AAkeb,kDAAmB;AAje5C,MAAM,eAAe,GAAG,cAAI,CAAC,0BAA0B,CAAC;AAiehD,0CAAe;AAhevB,MAAM,gCAAgC,GAAG,CAAC,CAAC;AAgeqB,4EAAgC;AA/dhG,yCAAyC;AACzC,iFAAiF;AACjF,MAAM,eAAe,GAAG,MAAM,CAAC;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