@browserless/screenshot 10.3.0 → 10.4.0

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.
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@browserless/screenshot",
3
3
  "description": "Take a clean screenshot of any website",
4
4
  "homepage": "https://browserless.js.org/#/?id=screenshoturl-options",
5
- "version": "10.3.0",
5
+ "version": "10.4.0",
6
6
  "main": "src/index.js",
7
7
  "author": {
8
8
  "email": "hello@microlink.io",
@@ -28,7 +28,7 @@
28
28
  "screenshot"
29
29
  ],
30
30
  "dependencies": {
31
- "@browserless/goto": "^10.3.0",
31
+ "@browserless/goto": "^10.4.0",
32
32
  "@kikobeats/time-span": "~1.0.3",
33
33
  "debug-logfmt": "~1.2.1",
34
34
  "got": "~11.8.6",
@@ -61,7 +61,7 @@
61
61
  "timeout": "2m",
62
62
  "workerThreads": false
63
63
  },
64
- "gitHead": "6de02ac566c97aa7f31a3faaca0a02668884cd9c",
64
+ "gitHead": "34f2f68010cd352fc6865efeda9573b516f211b9",
65
65
  "scripts": {
66
66
  "coverage": "exit 0",
67
67
  "test": "ava"
@@ -8,8 +8,12 @@ module.exports = async buffer => {
8
8
  const height = image.getHeight()
9
9
  const width = image.getWidth()
10
10
 
11
- for (let i = 0; i < height; i++) {
12
- for (let j = 0; j < width; j++) {
11
+ const samplePercentage = 0.25 // Sample 25% of the image
12
+ const sampleSize = Math.floor(width * height * samplePercentage) // Calculate sample size based on percentage
13
+ const stepSize = Math.max(1, Math.floor((width * height) / sampleSize)) // Calculate step size based on sample size
14
+
15
+ for (let i = 0; i < height; i += stepSize) {
16
+ for (let j = 0; j < width; j += stepSize) {
13
17
  if (firstPixel !== image.getPixelColor(j, i)) return false
14
18
  }
15
19
  }