Skip to content

Commit

Permalink
perf(screenshot): cache height & width values
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed Oct 5, 2022
1 parent fb34a19 commit f3b9a07
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/screenshot/src/is-white-screenshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ const jimp = require('jimp')
module.exports = async buffer => {
const image = await jimp.read(buffer)
const firstPixel = image.getPixelColor(0, 0)
const height = image.getHeight()
const width = image.getWidth()

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

0 comments on commit f3b9a07

Please sign in to comment.