canvacord
Advanced tools
Comparing version 2.0.6 to 3.0.0
{ | ||
"name": "canvacord", | ||
"version": "2.0.6", | ||
"description": "Simple & easy to use image manipulation module.", | ||
"version": "3.0.0", | ||
"description": "Simple & easy to use image manipulation module for discord bots with a lot of features like rank card, memes & more...", | ||
"main": "index.js", | ||
@@ -25,3 +25,10 @@ "scripts": { | ||
"welcomer", | ||
"leaver" | ||
"leaver", | ||
"dank-memer", | ||
"imagen", | ||
"imgen", | ||
"imagegen", | ||
"canvas", | ||
"jimp", | ||
"api" | ||
], | ||
@@ -35,3 +42,3 @@ "author": "Snowflake107", | ||
"gifencoder": "^2.0.1", | ||
"jimp": "^0.12.0" | ||
"jimp": "^0.13.0" | ||
}, | ||
@@ -38,0 +45,0 @@ "devDependencies": { |
@@ -18,31 +18,3 @@ # Canvacord | ||
# Functions | ||
- batslap(image1, image2) | ||
- beautiful(image) | ||
- facepalm(image) | ||
- gay(image) | ||
- kiss(image1, image2) | ||
- rip(image) | ||
- spank(image1, image2) | ||
- trash(image) | ||
- blur(image, level = 5) | ||
- greyscale(image) | ||
- sepia(image) | ||
- invert(image) | ||
- delete(image) | ||
- color(color_hex_or_html5_color_name) | ||
- trigger(image) | ||
- hitler(image) | ||
- bed(image1, image2) | ||
- wanted(image) | ||
- circle(image) | ||
- jail(image) | ||
- dither(image) | ||
- wasted(image) | ||
- welcomer({ username, discrim, avatarURL }) | ||
- leaver({ username, discrim, avatarURL }) | ||
- rank({ username, discrim, level, rank, neededXP, currentXP, avatarURL, color, background }) | ||
- read(ImageOrBuffer) | ||
- pixelate(image, level) | ||
- write(buffer, filename) | ||
- jokeoverthehead(image) | ||
**[Functions are listed here](https://canvacord.snowflakedev.cf/canvacord)** | ||
@@ -99,9 +71,9 @@ # Example | ||
discrim, | ||
level, | ||
rank, | ||
neededXP, | ||
currentXP, | ||
avatarURL, | ||
color, | ||
background | ||
level: rank.level, | ||
rank: rank.rank, | ||
neededXP: rank.neededXP, | ||
currentXP: rank.currentXP, | ||
avatarURL: message.author.displayAvatarURL({ format: "png" }), | ||
color: "white", | ||
background: "https://link-to/superDuperBackground" | ||
}); | ||
@@ -123,6 +95,33 @@ let attachment = new Discord.MessageAttachment(image, "rank.png"); | ||
# Rank Card | ||
![rankCard](https://media.discordapp.net/attachments/715806802670780436/723768235714936832/rank.png) | ||
# Change My Mind | ||
![img](https://raw.githubusercontent.com/Snowflake107/canvacord/master/test/changemymind.png) | ||
# Rank Cards | ||
## Default | ||
![img](https://raw.githubusercontent.com/Snowflake107/canvacord/master/test/rank-default.png) | ||
## Custom Background & Color | ||
![img](https://raw.githubusercontent.com/Snowflake107/canvacord/master/test/rank-custom-bg-and-color.png) | ||
## Custom Background & No Overlay | ||
![img](https://raw.githubusercontent.com/Snowflake107/canvacord/master/test/rank-custom-bg-no-overlay.png) | ||
## Custom Background | ||
![img](https://raw.githubusercontent.com/Snowflake107/canvacord/master/test/rank-custom-bg.png) | ||
## Custom Background, Color & No Overlay | ||
![img](https://raw.githubusercontent.com/Snowflake107/canvacord/master/test/rank-custom-color-bg-no-overlay.png) | ||
## Custom Color | ||
![img](https://raw.githubusercontent.com/Snowflake107/canvacord/master/test/rank-custom-color.png) | ||
# Triggered | ||
![img](https://raw.githubusercontent.com/Snowflake107/canvacord/master/test/triggered.gif) | ||
# Color | ||
![img](https://raw.githubusercontent.com/Snowflake107/canvacord/master/test/color.png) | ||
> ### Read the docs for more endpoints | ||
# Join Our Discord Server | ||
**[discord.gg/uqB8kxh](https://discord.gg/uqB8kxh)** |
@@ -21,2 +21,3 @@ /** | ||
const fs = require('fs'); | ||
const Util = require('./CanvasUtil'); | ||
@@ -54,4 +55,7 @@ // load custom plugins | ||
'blur', | ||
'changemymind', | ||
'circle', | ||
'color', | ||
'createQRCode', | ||
'deepfry', | ||
'delete', | ||
@@ -65,3 +69,3 @@ 'dither', | ||
'jail', | ||
'jokeoverthehead', | ||
'jokeoverhead', | ||
'kiss', | ||
@@ -74,4 +78,6 @@ 'leave', | ||
'read', | ||
'replaceColor', | ||
'rip', | ||
'sepia', | ||
'shit', | ||
'spank', | ||
@@ -84,3 +90,4 @@ 'trash', | ||
'welcomer', | ||
'write' | ||
'write', | ||
'youtube' | ||
]; | ||
@@ -100,3 +107,3 @@ } | ||
if (!image2) throw new Error('second image was not provided!'); | ||
let base = await jimp.read(__dirname + '/assets/batslap.png'); | ||
let base = await jimp.read(__dirname + '/assets/images/batslap.png'); | ||
image1 = await jimp.read(image1); | ||
@@ -122,3 +129,3 @@ image2 = await jimp.read(image2); | ||
if (!image) throw new Error('image was not provided!'); | ||
let base = await jimp.read(__dirname + '/assets/beautiful.png'); | ||
let base = await jimp.read(__dirname + '/assets/images/beautiful.png'); | ||
base.resize(376, 400); | ||
@@ -148,3 +155,3 @@ let img = await jimp.read(image); | ||
ctx.drawImage(avatar, 199, 112, 235, 235); | ||
let layer = await Canvas.loadImage(__dirname + '/assets/facepalm.png'); | ||
let layer = await Canvas.loadImage(__dirname + '/assets/images/facepalm.png'); | ||
ctx.drawImage(layer, 0, 0, 632, 357); | ||
@@ -163,3 +170,3 @@ return canvas.toBuffer(); | ||
if (!image) throw new Error('image was not provided!'); | ||
let bg = await Canvas.loadImage(__dirname + '/assets/gay.png'); | ||
let bg = await Canvas.loadImage(__dirname + '/assets/images/gay.png'); | ||
let img = await Canvas.loadImage(image); | ||
@@ -186,3 +193,3 @@ const canvas = Canvas.createCanvas(400, 400); | ||
const ctx = canvas.getContext('2d'); | ||
const background = await Canvas.loadImage(__dirname + '/assets/kiss.png'); | ||
const background = await Canvas.loadImage(__dirname + '/assets/images/kiss.png'); | ||
ctx.drawImage(background, 0, 0, canvas.width, canvas.height); | ||
@@ -207,3 +214,3 @@ const avatar = await Canvas.loadImage(image1); | ||
const ctx = canvas.getContext('2d'); | ||
const background = await Canvas.loadImage(__dirname + '/assets/rip.png'); | ||
const background = await Canvas.loadImage(__dirname + '/assets/images/rip.png'); | ||
ctx.drawImage(background, 0, 0, canvas.width, canvas.height); | ||
@@ -226,3 +233,3 @@ const avatar = await Canvas.loadImage(image); | ||
if (!image2) throw new Error('second image was not provided!'); | ||
let bg = await jimp.read(__dirname + '/assets/spank.png'); | ||
let bg = await jimp.read(__dirname + '/assets/images/spank.png'); | ||
image1 = await jimp.read(image1); | ||
@@ -248,3 +255,3 @@ image2 = await jimp.read(image2); | ||
if (!image) throw new Error('image was not provided!'); | ||
let bg = await jimp.read(__dirname + '/assets/trash.png'); | ||
let bg = await jimp.read(__dirname + '/assets/images/trash.png'); | ||
image = await jimp.read(image); | ||
@@ -328,3 +335,3 @@ image.resize(309, 309); | ||
if (!image) throw new Error('image was not provided!'); | ||
let bg = await jimp.read(__dirname + '/assets/delete.png'); | ||
let bg = await jimp.read(__dirname + '/assets/images/delete.png'); | ||
image = await jimp.read(image); | ||
@@ -362,9 +369,3 @@ image.resize(195, 195); | ||
_getHex(color) { | ||
if (!color) return '#000000'; | ||
if (color === 'RANDOM') return '#' + Math.floor(Math.random() * (0xffffff + 1)).toString(16); | ||
if (Array.isArray(color)) return '#' + ((color[0] << 16) + (color[1] << 8) + color[2]).toString(16); | ||
if (isNaN(color) && (color.startsWith('#') || color.startsWith('0x'))) return color.replace('0x', '#'); | ||
if (!isNaN(color) && String(color).startsWith('0x')) return String(color).replace('0x', '#'); | ||
if (!isNaN(color)) return `#${color.toString(16)}`; | ||
return color; | ||
Util.resolveColor(color); | ||
} | ||
@@ -381,3 +382,3 @@ | ||
if (!image) throw new Error('image was not provided!'); | ||
const base = await Canvas.loadImage(__dirname + '/assets/triggered.png'); | ||
const base = await Canvas.loadImage(__dirname + '/assets/images/triggered.png'); | ||
const img = await Canvas.loadImage(image); | ||
@@ -427,3 +428,3 @@ const GIF = new GIFEncoder(256, 310); | ||
if (!image) throw new Error('Image was not provided!'); | ||
let bg = await jimp.read(__dirname + '/assets/hitler.png'); | ||
let bg = await jimp.read(__dirname + '/assets/images/hitler.png'); | ||
let img = await jimp.read(image); | ||
@@ -447,3 +448,3 @@ img.resize(140, 140); | ||
if (!image2) throw new Error('second image was not provided!'); | ||
let bg = await jimp.read(__dirname + '/assets/bed.png'); | ||
let bg = await jimp.read(__dirname + '/assets/images/bed.png'); | ||
image1 = await jimp.read(image1); | ||
@@ -471,3 +472,3 @@ image2 = await jimp.read(image2); | ||
if (!image) throw new Error('no image provided!'); | ||
let base = await jimp.read(__dirname + '/assets/wanted.png'); | ||
let base = await jimp.read(__dirname + '/assets/images/wanted.png'); | ||
let img = await jimp.read(image); | ||
@@ -511,3 +512,3 @@ img.resize(447, 447); | ||
ctx.drawImage(avatar, 0, 0, 350, 350); | ||
let layer = await Canvas.loadImage(__dirname + '/assets/jail.png'); | ||
let layer = await Canvas.loadImage(__dirname + '/assets/images/jail.png'); | ||
ctx.drawImage(layer, 0, 0, 350, 350); | ||
@@ -526,3 +527,3 @@ return canvas.toBuffer(); | ||
if (!image) throw new Error('no image provided!'); | ||
let base = await jimp.read(__dirname + '/assets/affect.png'); | ||
let base = await jimp.read(__dirname + '/assets/images/affect.png'); | ||
let img = await jimp.read(image); | ||
@@ -561,3 +562,3 @@ img.resize(200, 157); | ||
const ctx = canvas.getContext('2d'); | ||
const base = await Canvas.loadImage(__dirname + '/assets/wasted.png'); | ||
const base = await Canvas.loadImage(__dirname + '/assets/images/wasted.png'); | ||
const img = await Canvas.loadImage(converted); | ||
@@ -581,3 +582,3 @@ ctx.drawImage(img, 0, 0, 500, 500); | ||
/** | ||
* rank | ||
* rank card | ||
* @param {String} username Username | ||
@@ -592,2 +593,3 @@ * @param {String} discrim Discriminator | ||
* @param {String|Buffer} background Rank card background image | ||
* @param {Boolean} overlay Keep overlay or not | ||
* @returns {Promise<Buffer>} | ||
@@ -597,3 +599,3 @@ * @example let img = await canva.rank({ username: "Snowflake", discrim: "0007", level: 4, rank: 12, neededXP: 500, currentXP: 407, avatarURL: "...", color: "#FFFFFF" }); | ||
*/ | ||
async rank({ username, discrim, level, rank, neededXP, currentXP, avatarURL, color, background }) { | ||
async rank({ username, discrim, level, rank, neededXP, currentXP, avatarURL, color, background, overlay }) { | ||
if (!username) throw new Error('No username was provided!'); | ||
@@ -606,4 +608,5 @@ if (!level) throw new Error('No level was provided!'); | ||
if (!color || typeof color !== 'string') color = '#FFFFFF'; | ||
if (overlay !== false) overlay = true; | ||
Canvas.registerFont(__dirname + '/assets/regular-font.ttf', { | ||
Canvas.registerFont(__dirname + '/assets/fonts/regular-font.ttf', { | ||
family: 'Manrope', | ||
@@ -613,3 +616,3 @@ weight: 'regular', | ||
}); | ||
Canvas.registerFont(__dirname + '/assets/bold-font.ttf', { | ||
Canvas.registerFont(__dirname + '/assets/fonts/bold-font.ttf', { | ||
family: 'Manrope', | ||
@@ -619,21 +622,2 @@ weight: 'bold', | ||
}); | ||
const convert = (num) => { | ||
if (!num) return NaN; | ||
if (typeof num === 'string') num = parseInt(num); | ||
let decPlaces = Math.pow(10, 1); | ||
var abbrev = ['K', 'M', 'B', 'T']; | ||
for (var i = abbrev.length - 1; i >= 0; i--) { | ||
var size = Math.pow(10, (i + 1) * 3); | ||
if (size <= num) { | ||
num = Math.round((num * decPlaces) / size) / decPlaces; | ||
if (num == 1000 && i < abbrev.length - 1) { | ||
num = 1; | ||
i++; | ||
} | ||
num += abbrev[i]; | ||
break; | ||
} | ||
} | ||
return num; | ||
}; | ||
const canvas = Canvas.createCanvas(934, 282); | ||
@@ -643,7 +627,11 @@ const ctx = canvas.getContext('2d'); | ||
let rankCard; | ||
if (typeof background === 'string' || Buffer.isBuffer(background)) { | ||
if ((overlay && typeof background === 'string') || Buffer.isBuffer(background)) { | ||
bg = await Canvas.loadImage(background); | ||
ctx.drawImage(bg, 0, 0, canvas.width, canvas.height); | ||
rankCard = await Canvas.loadImage(__dirname + '/assets/rankcard2.png'); | ||
} else rankCard = await Canvas.loadImage(__dirname + '/assets/rankcard.png'); | ||
rankCard = await Canvas.loadImage(__dirname + '/assets/images/rankcard2.png'); | ||
} else if (!overlay && (typeof background === 'string' || Buffer.isBuffer(background))) { | ||
bg = await Canvas.loadImage(background); | ||
ctx.drawImage(bg, 0, 0, canvas.width, canvas.height); | ||
rankCard = await Canvas.loadImage(__dirname + '/assets/images/rankcard3.png'); | ||
} else rankCard = await Canvas.loadImage(__dirname + '/assets/images/rankcard.png'); | ||
ctx.drawImage(rankCard, 0, 0, canvas.width, canvas.height); | ||
@@ -656,3 +644,3 @@ | ||
ctx.textAlign = 'start'; | ||
const name = username.length >= 10 ? username.substring(0, 70).trim() + '...' : username; | ||
const name = username.length >= 10 ? username.substring(0, 7).trim() + '...' : username; | ||
ctx.fillText(`${name}`, 264, 164); | ||
@@ -692,5 +680,5 @@ ctx.font = `36px ${font}`; | ||
ctx.textAlign = 'start'; | ||
ctx.fillText('/ ' + convert(neededXP), 670 + ctx.measureText(convert(currentXP)).width + 15, 164); | ||
ctx.fillText('/ ' + Util.toAbbrev(neededXP), 670 + ctx.measureText(Util.toAbbrev(currentXP)).width + 15, 164); | ||
ctx.fillStyle = color; | ||
ctx.fillText(convert(currentXP), 670, 164); | ||
ctx.fillText(Util.toAbbrev(currentXP), 670, 164); | ||
@@ -723,3 +711,3 @@ let widthXP = (currentXP * 615) / neededXP; | ||
/** | ||
* rank | ||
* rank card | ||
* @param {String} username Username | ||
@@ -734,7 +722,10 @@ * @param {String} discrim Discriminator | ||
* @param {String|Buffer} background Rank card background image | ||
* @param {Boolean} overlay Keep overlay or not | ||
* @returns {Promise<Buffer>} | ||
* @example let img = await canva.rank({ username: "Snowflake", discrim: "0007", level: 4, rank: 12, neededXP: 500, currentXP: 407, avatarURL: "...", color: "#FFFFFF" }); | ||
* canva.write(img, "img.png"); | ||
* @deprecated use Canvacord.rank() instead | ||
*/ | ||
async rankCard(...options) { | ||
console.warn('[Depreciated] Use Canvacord.rank() instead'); | ||
return this.rank(...options); | ||
@@ -758,3 +749,3 @@ } | ||
Canvas.registerFont(__dirname + '/assets/regular-font.ttf', { | ||
Canvas.registerFont(__dirname + '/assets/fonts/regular-font.ttf', { | ||
family: 'Manrope', | ||
@@ -764,3 +755,3 @@ weight: 'regular', | ||
}); | ||
Canvas.registerFont(__dirname + '/assets/bold-font.ttf', { | ||
Canvas.registerFont(__dirname + '/assets/fonts/bold-font.ttf', { | ||
family: 'Manrope', | ||
@@ -774,3 +765,3 @@ weight: 'bold', | ||
const background = await Canvas.loadImage(__dirname + '/assets/welcomebg.png'); | ||
const background = await Canvas.loadImage(__dirname + '/assets/images/welcomebg.png'); | ||
ctx.drawImage(background, 0, 0, canvas.width, canvas.height); | ||
@@ -850,3 +841,3 @@ | ||
Canvas.registerFont(__dirname + '/assets/regular-font.ttf', { | ||
Canvas.registerFont(__dirname + '/assets/fonts/regular-font.ttf', { | ||
family: 'Manrope', | ||
@@ -856,3 +847,3 @@ weight: 'regular', | ||
}); | ||
Canvas.registerFont(__dirname + '/assets/bold-font.ttf', { | ||
Canvas.registerFont(__dirname + '/assets/fonts/bold-font.ttf', { | ||
family: 'Manrope', | ||
@@ -866,3 +857,3 @@ weight: 'bold', | ||
const background = await Canvas.loadImage(__dirname + '/assets/welcomebg.png'); | ||
const background = await Canvas.loadImage(__dirname + '/assets/images/welcomebg.png'); | ||
ctx.drawImage(background, 0, 0, canvas.width, canvas.height); | ||
@@ -960,2 +951,4 @@ | ||
* @returns {Promise<Buffer>} | ||
* @example let img = await canva.jokeoverhead(image); | ||
* canva.write(img, "img.png"); | ||
*/ | ||
@@ -970,8 +963,194 @@ async jokeoverhead(image) { | ||
ctx.drawImage(image, 125, 130, 140, 135); | ||
let layer = await Canvas.loadImage(__dirname + '/assets/jokeoverhead.png'); | ||
let layer = await Canvas.loadImage(__dirname + '/assets/images/jokeoverhead.png'); | ||
ctx.drawImage(layer, 0, 0, 425, 404); | ||
return canvas.toBuffer(); | ||
} | ||
/** | ||
* Blurplefy the image | ||
* @param {String|Buffer} image Image to manipulate | ||
* @param {Number} r Red color placeholder | ||
* @param {Number} g Green color placeholder | ||
* @param {Number} b Blue color placeholder | ||
* @returns {Promise<Buffer>} | ||
* @example let img = await canva.replaceColor(image, { r, g, b }); | ||
* canva.write(img, "img.png"); | ||
*/ | ||
async replaceColor(image, { r, g, b }) { | ||
if (!image) throw new Error('No image provided!'); | ||
image = await jimp.read(image); | ||
if (Array.isArray(r) && Array.isArray(g) && Array.isArray(b)) { | ||
image.color([ | ||
{ apply: 'red', params: r }, | ||
{ apply: 'green', params: g }, | ||
{ apply: 'blue', params: b } | ||
]); | ||
} | ||
if (!r || !g || !b || isNaN(r) || isNaN(g) || isNaN(b)) return image; | ||
image.color([ | ||
{ apply: 'red', params: [parseInt(r)] }, | ||
{ apply: 'green', params: [parseInt(g)] }, | ||
{ apply: 'blue', params: [parseInt(b)] } | ||
]); | ||
return await image.getBufferAsync('image/png'); | ||
} | ||
/** | ||
* Change my mind | ||
* @param {String} text Text | ||
* @returns {Promise<Buffer>} | ||
* @example let img = await canva.changemymind(text); | ||
* canva.write(img, "img.png"); | ||
*/ | ||
async changemymind(text) { | ||
if (!text) throw new Error('No text was provided!'); | ||
const base = await Canvas.loadImage(__dirname + '/assets/images/changemymind.jpg'); | ||
const canvas = Canvas.createCanvas(base.width, base.height); | ||
const ctx = canvas.getContext('2d'); | ||
ctx.drawImage(base, 0, 0, canvas.width, canvas.height); | ||
let x = text.length; | ||
let fontSize = 70; | ||
if (x <= 15) { | ||
ctx.translate(310, 365); | ||
} else if (x <= 30) { | ||
fontSize = 50; | ||
ctx.translate(315, 365); | ||
} else if (x <= 70) { | ||
fontSize = 40; | ||
ctx.translate(315, 365); | ||
} else if (x <= 85) { | ||
fontSize = 32; | ||
ctx.translate(315, 365); | ||
} else if (x < 100) { | ||
fontSize = 26; | ||
ctx.translate(315, 365); | ||
} else if (x < 120) { | ||
fontSize = 21; | ||
ctx.translate(315, 365); | ||
} else if (x < 180) { | ||
fontSize = 0.0032 * (x * x) - 0.878 * x + 80.545; | ||
ctx.translate(315, 365); | ||
} else if (x < 700) { | ||
fontSize = 0.0000168 * (x * x) - 0.0319 * x + 23.62; | ||
ctx.translate(310, 338); | ||
} else { | ||
fontSize = 7; | ||
ctx.translate(310, 335); | ||
} | ||
ctx.font = `${fontSize}px 'Arial'`; | ||
ctx.rotate(-0.39575); | ||
const lines = Util.getLines({ text, ctx, maxWidth: 345 }); | ||
let i = 0; | ||
while (i < lines.length) { | ||
ctx.fillText(lines[i], 10, i * fontSize - 5); | ||
i++; | ||
} | ||
return canvas.toBuffer(); | ||
} | ||
/** | ||
* Deepfry the image | ||
* @param {String|Buffer} image image to deepfry | ||
* @returns {Promise<Buffer>} | ||
* @example let img = await canva.deepfry(image); | ||
* canva.write(img, "img.png"); | ||
*/ | ||
async deepfry(image) { | ||
if (!image) throw new Error('No image provided!'); | ||
image = await Canvas.loadImage(image); | ||
const canvas = Canvas.createCanvas(image.width, image.height); | ||
const ctx = canvas.getContext('2d'); | ||
ctx.drawImage(image, 0, 0, image.width, image.height); | ||
ctx.globalAlpha = 0; | ||
ctx.fillStyle = '#FF591A'; | ||
ctx.fillRect(0, 0, image.width, image.height); | ||
ctx.globalAlpha = 1.0; | ||
ctx.globalCompositeOperation = 'saturation'; | ||
ctx.fillStyle = 'hsl(0, 100%, 50%)'; | ||
ctx.fillRect(0, 0, image.width, image.height); | ||
ctx.globalCompositeOperation = 'source-over'; | ||
let data = ctx.getImageData(0, 0, image.width, image.height); | ||
data = Util.brightnessContrastPhotoshop(data, 52, 60); | ||
ctx.putImageData(data, 0, 0); | ||
data = Util.brightnessContrastPhotoshop(data, 32, 40); | ||
data = Util.grain(data); | ||
ctx.putImageData(data, 0, 0); | ||
return canvas.toBuffer(); | ||
} | ||
/** | ||
* Creates qr code | ||
* @param {String} text text for the qr code | ||
* @param {Object} options QR code options | ||
* @param {String} [options.color] QR Code color | ||
* @param {String} [options.background] Background color of the qr code | ||
* @returns {Promise<Buffer>} | ||
* @example let img = await canva.createQRCode(text); | ||
* canva.write(img, "img.png"); | ||
*/ | ||
async createQRCode(text, options = { background: '#FFFFFF', color: '#000000' }) { | ||
if (!text) throw new Error('No text specified!'); | ||
let img = `https://api.qrserver.com/v1/create-qr-code/?size=1024x1024&data=${encodeURIComponent( | ||
text | ||
)}&color=${options.color.replace('#', '')}&bgcolor=${options.background.replace('#', '')}`; | ||
img = await jimp.read(img); | ||
return await img.getBufferAsync('image/png'); | ||
} | ||
/** | ||
* YouTube comment | ||
* @param {String|Buffer} image Image | ||
* @param {String} username Username | ||
* @param {String} comment Comment | ||
* @returns {Promise<Buffer>} | ||
* @example let img = await canva.youtube(image, "PewDiePie", "B*tch Lasagna"); | ||
* canva.write(img, "img.png"); | ||
*/ | ||
async youtube(image, username, comment) { | ||
if (!image) throw new Error('No image provided!'); | ||
if (!username) throw new Error('No username provided!'); | ||
if (!comment) throw new Error('No comment provided!'); | ||
let base = await jimp.read(__dirname + '/assets/images/youtube.png'); | ||
base.resize(650, 183); | ||
let avatar = await await jimp.read(await this.circle(image)); | ||
avatar.resize(52, 52); | ||
base.composite(avatar, 17, 33); | ||
let font = await jimp.loadFont(jimp.FONT_SANS_16_BLACK); | ||
let time = Math.floor(Math.random() * (59 - 1)) + 1; | ||
time = `${time + (time == 1 ? ' minute' : ' minutes')} ago`; | ||
base.print(font, 92, 34, username.substr(0, 20)); | ||
base.print(font, 200, 34, time); | ||
base.print(font, 92, 59, comment.substr(0, 40)); | ||
return await base.getBufferAsync('image/png'); | ||
} | ||
/** | ||
* Ew, I stepped in shit... | ||
* @param {String|Buffer} image Image source | ||
* @returns {Promise<Buffer>} | ||
* @example let img = await canva.shit(image); | ||
* canva.write(img, "img.png"); | ||
*/ | ||
async shit(image) { | ||
if (!image) throw new Error('No image provided!'); | ||
image = await jimp.read(image); | ||
image.resize(170, 170); | ||
let base = await jimp.read(__dirname + '/assets/images/shit.png'); | ||
image.rotate(52, false); | ||
base.composite(image, 210, 700); | ||
return await base.getBufferAsync('image/png'); | ||
} | ||
} | ||
module.exports = Canvacord; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 2 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 2 instances in 1 package
2986658
32
1135
125
+ Added@jimp/bmp@0.13.0(transitive)
+ Added@jimp/gif@0.13.0(transitive)
+ Added@jimp/jpeg@0.13.0(transitive)
+ Added@jimp/plugin-blit@0.13.0(transitive)
+ Added@jimp/plugin-blur@0.13.0(transitive)
+ Added@jimp/plugin-color@0.13.0(transitive)
+ Added@jimp/plugin-contain@0.13.0(transitive)
+ Added@jimp/plugin-cover@0.13.0(transitive)
+ Added@jimp/plugin-crop@0.13.0(transitive)
+ Added@jimp/plugin-displace@0.13.0(transitive)
+ Added@jimp/plugin-dither@0.13.0(transitive)
+ Added@jimp/plugin-fisheye@0.13.0(transitive)
+ Added@jimp/plugin-flip@0.13.0(transitive)
+ Added@jimp/plugin-gaussian@0.13.0(transitive)
+ Added@jimp/plugin-invert@0.13.0(transitive)
+ Added@jimp/plugin-mask@0.13.0(transitive)
+ Added@jimp/plugin-normalize@0.13.0(transitive)
+ Added@jimp/plugin-print@0.13.0(transitive)
+ Added@jimp/plugin-resize@0.13.0(transitive)
+ Added@jimp/plugin-rotate@0.13.0(transitive)
+ Added@jimp/plugin-scale@0.13.0(transitive)
+ Added@jimp/plugin-shadow@0.13.0(transitive)
+ Added@jimp/plugin-threshold@0.13.0(transitive)
+ Added@jimp/plugins@0.13.0(transitive)
+ Added@jimp/png@0.13.0(transitive)
+ Added@jimp/tiff@0.13.0(transitive)
+ Added@jimp/types@0.13.0(transitive)
+ Added@types/node@16.9.1(transitive)
+ Addedgifwrap@0.9.4(transitive)
+ Addedimage-q@4.0.0(transitive)
+ Addedjimp@0.13.0(transitive)
- Removed@jimp/bmp@0.12.1(transitive)
- Removed@jimp/core@0.12.1(transitive)
- Removed@jimp/custom@0.12.1(transitive)
- Removed@jimp/gif@0.12.1(transitive)
- Removed@jimp/jpeg@0.12.1(transitive)
- Removed@jimp/plugin-blit@0.12.1(transitive)
- Removed@jimp/plugin-blur@0.12.1(transitive)
- Removed@jimp/plugin-circle@0.12.1(transitive)
- Removed@jimp/plugin-color@0.12.1(transitive)
- Removed@jimp/plugin-contain@0.12.1(transitive)
- Removed@jimp/plugin-cover@0.12.1(transitive)
- Removed@jimp/plugin-crop@0.12.1(transitive)
- Removed@jimp/plugin-displace@0.12.1(transitive)
- Removed@jimp/plugin-dither@0.12.1(transitive)
- Removed@jimp/plugin-fisheye@0.12.1(transitive)
- Removed@jimp/plugin-flip@0.12.1(transitive)
- Removed@jimp/plugin-gaussian@0.12.1(transitive)
- Removed@jimp/plugin-invert@0.12.1(transitive)
- Removed@jimp/plugin-mask@0.12.1(transitive)
- Removed@jimp/plugin-normalize@0.12.1(transitive)
- Removed@jimp/plugin-print@0.12.1(transitive)
- Removed@jimp/plugin-resize@0.12.1(transitive)
- Removed@jimp/plugin-rotate@0.12.1(transitive)
- Removed@jimp/plugin-scale@0.12.1(transitive)
- Removed@jimp/plugin-shadow@0.12.1(transitive)
- Removed@jimp/plugin-threshold@0.12.1(transitive)
- Removed@jimp/plugins@0.12.1(transitive)
- Removed@jimp/png@0.12.1(transitive)
- Removed@jimp/tiff@0.12.1(transitive)
- Removed@jimp/types@0.12.1(transitive)
- Removed@jimp/utils@0.12.1(transitive)
- Removedjimp@0.12.1(transitive)
Updatedjimp@^0.13.0