Skip to content

Commit

Permalink
build: update jimp
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed Sep 3, 2024
1 parent e2f7375 commit ffaf9be
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 5 deletions.
23 changes: 23 additions & 0 deletions packages/cli/src/commands/favicon.js
Original file line number Diff line number Diff line change
@@ -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!'
)}`
})
]
}
2 changes: 1 addition & 1 deletion packages/screenshot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 4 additions & 4 deletions packages/screenshot/src/is-white-screenshot.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Empty file added script.js
Empty file.

0 comments on commit ffaf9be

Please sign in to comment.