diff --git a/packages/cli/src/commands/favicon.js b/packages/cli/src/commands/favicon.js new file mode 100644 index 000000000..558cade0a --- /dev/null +++ b/packages/cli/src/commands/favicon.js @@ -0,0 +1,23 @@ +'use strict' + +const { gray, yellow } = require('picocolors') +const termImg = require('term-img') + +module.exports = async ({ url, browserless, opts }) => { + opts.headers = { cookie: 'allowFavicon=true' } + const screenshot = await browserless.screenshot( + 'https://test-cookie-server.vercel.app/favicon.ico', + opts + ) + + return [ + screenshot, + termImg(Buffer.from(screenshot), { + width: '50%', + fallback: () => + `${opts.verbose ? '' : '\n'}${yellow(' tip:')} ${gray( + 'use iTerm >=3 to see the image here!' + )}` + }) + ] +} diff --git a/packages/screenshot/package.json b/packages/screenshot/package.json index a36ce578e..74a49b10c 100644 --- a/packages/screenshot/package.json +++ b/packages/screenshot/package.json @@ -34,7 +34,7 @@ "got": "~11.8.6", "is-html-content": "~1.0.0", "is-url-http": "~2.3.7", - "jimp": "~0.22.12", + "jimp": "~1.1.2", "map-values-deep": "~1.0.2", "mime": "~3.0.0", "p-reflect": "~2.1.0", diff --git a/packages/screenshot/src/is-white-screenshot.js b/packages/screenshot/src/is-white-screenshot.js index 63deac894..24b55ac4a 100644 --- a/packages/screenshot/src/is-white-screenshot.js +++ b/packages/screenshot/src/is-white-screenshot.js @@ -1,12 +1,12 @@ 'use strict' -const jimp = require('jimp') +const { Jimp } = require('jimp') module.exports = async uint8array => { - const image = await jimp.read(Buffer.from(uint8array)) + const image = await Jimp.fromBuffer(uint8array) const firstPixel = image.getPixelColor(0, 0) - const height = image.getHeight() - const width = image.getWidth() + 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 diff --git a/script.js b/script.js new file mode 100644 index 000000000..e69de29bb