Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [10.9.8](https://github.com/microlinkhq/browserless/compare/v10.9.7...v10.9.8) (2025-10-19)

### Bug Fixes

* **screenshot:** white sampling ([#636](https://github.com/microlinkhq/browserless/issues/636)) ([e12515a](https://github.com/microlinkhq/browserless/commit/e12515a2c435620bedec26f62f91296b96d6d2b1))

## [10.9.7](https://github.com/microlinkhq/browserless/compare/v10.9.6...v10.9.7) (2025-10-07)

**Note:** Version bump only for package browserless
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"packages": [
"packages/*"
],
"version": "10.9.7",
"version": "10.9.8",
"command": {
"bootstrap": {
"npmClientArgs": [
Expand Down
4 changes: 4 additions & 0 deletions packages/browserless/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [10.9.8](https://github.com/microlinkhq/browserless/compare/v10.9.7...v10.9.8) (2025-10-19)

**Note:** Version bump only for package browserless

## [10.9.7](https://github.com/microlinkhq/browserless/compare/v10.9.6...v10.9.7) (2025-10-07)

**Note:** Version bump only for package browserless
Expand Down
10 changes: 5 additions & 5 deletions packages/browserless/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "browserless",
"description": "The headless Chrome/Chromium performance driver for Node.js",
"homepage": "https://browserless.js.org",
"version": "10.9.7",
"version": "10.9.8",
"main": "src/index.js",
"author": {
"email": "hello@microlink.io",
Expand Down Expand Up @@ -32,9 +32,9 @@
],
"dependencies": {
"@browserless/errors": "^10.9.7",
"@browserless/goto": "^10.9.7",
"@browserless/pdf": "^10.9.7",
"@browserless/screenshot": "^10.9.7",
"@browserless/goto": "^10.9.8",
"@browserless/pdf": "^10.9.8",
"@browserless/screenshot": "^10.9.8",
"debug-logfmt": "~1.4.5",
"kill-process-group": "~1.0.13",
"p-reflect": "~2.1.0",
Expand All @@ -44,7 +44,7 @@
"superlock": "~1.2.4"
},
"devDependencies": {
"@browserless/test": "^10.9.7",
"@browserless/test": "^10.9.8",
"ava": "5",
"ps-list": "7",
"tinyspawn": "latest"
Expand Down
4 changes: 4 additions & 0 deletions packages/cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [10.9.8](https://github.com/microlinkhq/browserless/compare/v10.9.7...v10.9.8) (2025-10-19)

**Note:** Version bump only for package @browserless/cli

## [10.9.7](https://github.com/microlinkhq/browserless/compare/v10.9.6...v10.9.7) (2025-10-07)

**Note:** Version bump only for package @browserless/cli
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@browserless/cli",
"description": "CLI to interact with Browserless capabilities",
"homepage": "https://browserless.js.org",
"version": "10.9.7",
"version": "10.9.8",
"bin": {
"browserless": "src/index.js"
},
Expand Down Expand Up @@ -32,7 +32,7 @@
],
"dependencies": {
"beauty-error": "~1.2.21",
"browserless": "^10.9.7",
"browserless": "^10.9.8",
"dark-mode": "~3.0.0",
"dset": "~3.1.4",
"mri": "~1.2.0",
Expand Down
4 changes: 4 additions & 0 deletions packages/function/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [10.9.8](https://github.com/microlinkhq/browserless/compare/v10.9.7...v10.9.8) (2025-10-19)

**Note:** Version bump only for package @browserless/function

## [10.9.7](https://github.com/microlinkhq/browserless/compare/v10.9.6...v10.9.7) (2025-10-07)

**Note:** Version bump only for package @browserless/function
Expand Down
4 changes: 2 additions & 2 deletions packages/function/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@browserless/function",
"description": "Run abritrary JavaScript inside a browser sandbox",
"homepage": "https://browserless.js.org",
"version": "10.9.7",
"version": "10.9.8",
"main": "src/index.js",
"author": {
"email": "hello@microlink.io",
Expand Down Expand Up @@ -34,7 +34,7 @@
"require-one-of": "~1.0.24"
},
"devDependencies": {
"@browserless/test": "^10.9.7",
"@browserless/test": "^10.9.8",
"acorn": "~8.15.0",
"acorn-walk": "~8.3.4",
"ava": "5",
Expand Down
4 changes: 4 additions & 0 deletions packages/goto/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [10.9.8](https://github.com/microlinkhq/browserless/compare/v10.9.7...v10.9.8) (2025-10-19)

**Note:** Version bump only for package @browserless/goto

## [10.9.7](https://github.com/microlinkhq/browserless/compare/v10.9.6...v10.9.7) (2025-10-07)

**Note:** Version bump only for package @browserless/goto
Expand Down
4 changes: 2 additions & 2 deletions packages/goto/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@browserless/goto",
"description": "Go to a page aborting unnecessary requests",
"homepage": "https://browserless.js.org/#/?id=gotopage-options",
"version": "10.9.7",
"version": "10.9.8",
"main": "src/index.js",
"author": {
"email": "hello@microlink.io",
Expand Down Expand Up @@ -40,7 +40,7 @@
"tough-cookie": "~6.0.0"
},
"devDependencies": {
"@browserless/test": "^10.9.7",
"@browserless/test": "^10.9.8",
"ava": "5",
"p-wait-for": "3"
},
Expand Down
4 changes: 4 additions & 0 deletions packages/lighthouse/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [10.9.8](https://github.com/microlinkhq/browserless/compare/v10.9.7...v10.9.8) (2025-10-19)

**Note:** Version bump only for package @browserless/lighthouse

## [10.9.7](https://github.com/microlinkhq/browserless/compare/v10.9.6...v10.9.7) (2025-10-07)

**Note:** Version bump only for package @browserless/lighthouse
Expand Down
4 changes: 2 additions & 2 deletions packages/lighthouse/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@browserless/lighthouse",
"description": "Browserless Lighthouse integration using puppeteer.",
"homepage": "https://browserless.js.org",
"version": "10.9.7",
"version": "10.9.8",
"main": "src",
"repository": {
"type": "git",
Expand All @@ -27,7 +27,7 @@
"lighthouse": "~12.8.2"
},
"devDependencies": {
"@browserless/test": "^10.9.7",
"@browserless/test": "^10.9.8",
"ava": "5"
},
"engines": {
Expand Down
4 changes: 4 additions & 0 deletions packages/pdf/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [10.9.8](https://github.com/microlinkhq/browserless/compare/v10.9.7...v10.9.8) (2025-10-19)

**Note:** Version bump only for package @browserless/pdf

## [10.9.7](https://github.com/microlinkhq/browserless/compare/v10.9.6...v10.9.7) (2025-10-07)

**Note:** Version bump only for package @browserless/pdf
Expand Down
6 changes: 3 additions & 3 deletions packages/pdf/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@browserless/pdf",
"description": "Sensible good defaults for exporting a website as PDF",
"homepage": "https://browserless.js.org/#/?id=pdfurl-options",
"version": "10.9.7",
"version": "10.9.8",
"main": "src",
"repository": {
"directory": "packages/pdf",
Expand All @@ -24,8 +24,8 @@
"screen"
],
"dependencies": {
"@browserless/goto": "^10.9.7",
"@browserless/screenshot": "^10.9.7",
"@browserless/goto": "^10.9.8",
"@browserless/screenshot": "^10.9.8",
"@kikobeats/time-span": "~1.0.9",
"debug-logfmt": "~1.4.5",
"pretty-ms": "~7.0.1"
Expand Down
4 changes: 4 additions & 0 deletions packages/screencast/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [10.9.8](https://github.com/microlinkhq/browserless/compare/v10.9.7...v10.9.8) (2025-10-19)

**Note:** Version bump only for package @browserless/screencast

## [10.9.7](https://github.com/microlinkhq/browserless/compare/v10.9.6...v10.9.7) (2025-10-07)

**Note:** Version bump only for package @browserless/screencast
Expand Down
4 changes: 2 additions & 2 deletions packages/screencast/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@browserless/screencast",
"description": "Browserless frame capturing using puppeteer",
"homepage": "https://browserless.js.org/#/?id=screencasturl-options",
"version": "10.9.7",
"version": "10.9.8",
"main": "src/index.js",
"author": {
"email": "hello@microlink.io",
Expand Down Expand Up @@ -36,7 +36,7 @@
"null-prototype-object": "~1.2.3"
},
"devDependencies": {
"@browserless/test": "^10.9.7",
"@browserless/test": "^10.9.8",
"@kikobeats/time-span": "latest",
"@skyra/gifenc": "latest",
"ava": "5",
Expand Down
6 changes: 6 additions & 0 deletions packages/screenshot/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [10.9.8](https://github.com/microlinkhq/browserless/compare/v10.9.7...v10.9.8) (2025-10-19)

### Bug Fixes

* **screenshot:** white sampling ([#636](https://github.com/microlinkhq/browserless/issues/636)) ([e12515a](https://github.com/microlinkhq/browserless/commit/e12515a2c435620bedec26f62f91296b96d6d2b1))

## [10.9.7](https://github.com/microlinkhq/browserless/compare/v10.9.6...v10.9.7) (2025-10-07)

**Note:** Version bump only for package @browserless/screenshot
Expand Down
6 changes: 3 additions & 3 deletions packages/screenshot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@browserless/screenshot",
"description": "Take a clean screenshot of any website",
"homepage": "https://browserless.js.org/#/?id=screenshoturl-options",
"version": "10.9.7",
"version": "10.9.8",
"main": "src/index.js",
"author": {
"email": "hello@microlink.io",
Expand All @@ -28,7 +28,7 @@
"screenshot"
],
"dependencies": {
"@browserless/goto": "^10.9.7",
"@browserless/goto": "^10.9.8",
"@kikobeats/content-type": "~1.0.1",
"@kikobeats/time-span": "~1.0.9",
"debug-logfmt": "~1.4.5",
Expand All @@ -46,7 +46,7 @@
"svg-gradient": "~1.0.3"
},
"devDependencies": {
"@browserless/test": "^10.9.7",
"@browserless/test": "^10.9.8",
"ava": "5",
"cheerio": "latest"
},
Expand Down
34 changes: 22 additions & 12 deletions packages/screenshot/src/is-white-screenshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,30 @@
const { Jimp } = require('jimp')

module.exports = async uint8array => {
const image = await Jimp.fromBuffer(Buffer.from(uint8array))
const firstPixel = image.getPixelColor(0, 0)
const height = image.bitmap.height
const width = image.bitmap.width
try {
const image = await Jimp.fromBuffer(Buffer.from(uint8array))
const firstPixel = image.getPixelColor(0, 0)
const height = image.bitmap.height
const width = image.bitmap.width

const samplePercentage = 0.25 // Sample 25% of the image
const sampleSize = Math.floor(width * height * samplePercentage) // Calculate sample size based on percentage
const stepSize = Math.max(1, Math.floor((width * height) / sampleSize)) // Calculate step size based on sample size
// For 2D grid sampling, calculate stepSize to achieve approximately the target sample percentage.
// When sampling every 'stepSize' pixels in both dimensions, actual samples = (height/stepSize) * (width/stepSize).
// To achieve samplePercentage, we need: (h*w)/(stepSize²) ≈ samplePercentage*(h*w)
// Therefore: stepSize ≈ sqrt(1 / samplePercentage)
const samplePercentage = 0.25 // Sample ~25% of the image
const stepSize = Math.max(1, Math.ceil(Math.sqrt(1 / samplePercentage)))

for (let i = 0; i < height; i += stepSize) {
for (let j = 0; j < width; j += stepSize) {
if (firstPixel !== image.getPixelColor(j, i)) return false
for (let i = 0; i < height; i += stepSize) {
for (let j = 0; j < width; j += stepSize) {
if (firstPixel !== image.getPixelColor(j, i)) return false
}
}
}

return true
return true
} catch (error) {
if (error.message.includes('maxMemoryUsageInMB')) {
return false
}
throw error
}
}
63 changes: 63 additions & 0 deletions packages/screenshot/test/is-white-screenshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,36 @@
const test = require('ava')
const { readFile } = require('fs/promises')

const { Jimp } = require('jimp')

const isWhite = require('../src/is-white-screenshot')

const createJimpSpy = () => {
const originalFromBuffer = Jimp.fromBuffer
const spy = { callCount: 0 }

const wrappedFromBuffer = async function (buffer, options) {
const image = await originalFromBuffer.call(this, buffer, options)
const originalGetPixelColor = image.getPixelColor.bind(image)

image.getPixelColor = function (x, y) {
spy.callCount++
return originalGetPixelColor(x, y)
}

return image
}

Jimp.fromBuffer = wrappedFromBuffer

return {
spy,
restore: () => {
Jimp.fromBuffer = originalFromBuffer
}
}
}

test('true', async t => {
t.true(await isWhite(await readFile('./test/fixtures/white-5k.jpg')))
t.true(await isWhite(await readFile('./test/fixtures/white-5k.png')))
Expand All @@ -14,3 +42,38 @@ test('false', async t => {
t.false(await isWhite(await readFile('./test/fixtures/no-white-5k.jpg')))
t.false(await isWhite(await readFile('./test/fixtures/no-white-5k.png')))
})

test('sampling algorithm correctly samples ~25% of pixels', async t => {
const imageBuffer = await readFile('./test/fixtures/white-5k.png')
const tempImage = await Jimp.fromBuffer(imageBuffer)
const totalPixels = tempImage.bitmap.width * tempImage.bitmap.height
const { spy, restore } = createJimpSpy()

await isWhite(imageBuffer)
restore()

const percentageChecked = (spy.callCount / totalPixels) * 100

t.true(
percentageChecked >= 20 && percentageChecked <= 30,
`Expected to check ~25% of pixels, but checked ${percentageChecked.toFixed(2)}% (${
spy.callCount
}/${totalPixels})`
)
})

test('handles memory errors gracefully on very large images', async t => {
const { createCanvas } = require('canvas')

const width = 10000
const height = 10000
const canvas = createCanvas(width, height)
const ctx = canvas.getContext('2d')

ctx.fillStyle = '#ffffff'
ctx.fillRect(0, 0, width, height)

const largeImageBuffer = canvas.toBuffer('image/jpeg', { quality: 0.9 })
const result = await isWhite(largeImageBuffer)
t.is(typeof result, 'boolean', 'Should return a boolean, not throw an error')
})
Loading
Loading