Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
drawColor(hexColor, buttonNumber) {
let colors = Jimp.intToRGBA(hexColor)
// Because there's no alpha channel for hexColor, Jimp.intToRGBA() will offset each color by one place so that
// [colors.g, colors.b, colors.a] are actually [R, G, B].
let color = Buffer.from([colors.g, colors.b, colors.a])
let buffer = Buffer.alloc(ICON_SIZE * ICON_SIZE * 3, color)
this.drawImageBuffer(buffer, buttonNumber, false)
}
Jimp.read(imgName, (err, img) => {
if(err) throw err;
for(var i = 0; i < 30; i++){
for(var j = 0; j < 30; j++){
var hex = img.getPixelColor(j, i);
var rgb = Jimp.intToRGBA(hex);
var color = {
R: rgb.r,
G: rgb.g,
B: rgb.b
};
transColors.push(diff.closest(color, palette));
}
}
// get emoji name for every RGB value
var results = [];
for(var i = 0; i < transColors.length; i++){
var e2 = Object.values(transColors[i]);
for(var j = 0; j < emojiRgb.length; j++){
var e1 = Object.values(emojiRgb[j]).slice(0, -1);
function isBlue(pixel) {
var rgba = Jimp.intToRGBA(pixel);
var hsv = convert.rgb.hsl([rgba.r, rgba.g, rgba.b]);
// map mod blue:
// hue 240
// saturation + value > 40
// red and green components equal and both > 70
return (
hsv[0] <= 250
&& hsv[0] >= 235
&& hsv[1] + hsv[2] > 40
&& Math.abs(rgba.r - rgba.g) <= 10
&& rgba.r > 70
);
}
Jimp.read(sources[i].thumbnail.toPNG(), (err, img) => {
if (err) return console.log(err)
const pixelColor = img.getPixelColor(point.x, point.y)
const rgbaColor = Jimp.intToRGBA(pixelColor)
const hexColorString = `#${componentToHex(rgbaColor.r)}${componentToHex(rgbaColor.g)}${componentToHex(rgbaColor.b)}`
clipboard.writeText(hexColorString)
pushColor(hexColorString)
})
}
height = image.bitmap.height;
chunk = width / sanitizeFidelity(fidelity);
} catch (e) {
return reject(e);
}
const stops = [];
for (let i = 0; i < width; i += chunk) {
const color = image.clone()
.crop(i, 0, chunk, height)
.resize(1, 1, Jimp.RESIZE_BICUBIC)
.getPixelColor(0, 0);
stops.push({
color: rgbToHex(Jimp.intToRGBA(color)),
position: roundNumber(i * 100 / width, 2),
});
}
return resolve(stops);
});
});
function isColorVisableWellOnWhite(rgbColor) {
if (contrast(Jimp.intToRGBA(white), rgbColor) < 2 && rgbColor["r"] > 150 && rgbColor["g"] > 150 && rgbColor["b"] > 150) {
return false;
}
return true;
}
const splashBackground = background || (() => {
if (image.hasAlpha()) {
return null;
}
let topLeftColor = image.getPixelColor(0, 0);
let topRightColor = image.getPixelColor(image.bitmap.width - 1, 0);
let bottomLeftColor = image.getPixelColor(0, image.bitmap.height - 1);
let bottomRightColor = image.getPixelColor(image.bitmap.width - 1, image.bitmap.height - 1);
if (topLeftColor === topRightColor &&
topLeftColor === bottomLeftColor &&
topLeftColor === bottomRightColor) {
let color = Jimp.intToRGBA(topLeftColor);
color.alpha = 1;
return color;
}
return null;
})() || { r: 255, g: 255, b: 255, alpha: 1 };
const size = Math.round(Math.min(height / 6, width / 6)) - (gutterAlpha || 0);
image.scan(0, 0, image.bitmap.width, image.bitmap.height, function (x, y, idx) {
var color = image.getPixelColor(x, y);
var rgbColor = Jimp.intToRGBA(color);
if (y < 10 || x < 10 || x > image.bitmap.width - 10) { //Remove header text & side pixels
image.setPixelColor(white, x, y);
} else if (rgbColor["r"] > 200 && rgbColor["g"] > 200 && rgbColor["b"] > 200) { //remove light background
image.setPixelColor(white, x, y);
}
if (x == image.bitmap.width - 1 && y == image.bitmap.height - 1) { //Scan1 finished
image.background(white);
var orgImg = image.clone();
getAngleToStraightTheImage(image, 0, 1, image.bitmap.height, 0, function (angleToRotate) {
orgImg.rotate(angleToRotate);
changeAllPresentPixelsToBlack(orgImg, function (orgImg) {
//fillHoles(orgImg, 1, function(orgImg) {
//removeSpikes(orgImg, 1, function(orgImg) {
orgImg.write('temp.jpg', function () { //Print current image