adding text to pictures js using jimp - javascript

I got a picture file that I want to add text in specified locations, I thought of using jimp, so I turned my .ttf into .fnt in order to use it with jimp and I get this error:
Error: no named row at line 1
at splitLine (C:\\\node_modules\parse-bmfont-ascii\index.js:49:11)
at parseBMFontAscii (C:\Users\\node_modules\parse-bmfont-ascii\index.js:18:20)
at C:\Users\\node_modules\load-bmfont\index.js:39:18
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:511:3)
(node:11892) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:11892) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
I couldn't find any watermark module that have a font option as well, any advice on that?

Related

discord.js message.startThread() doesnt work

I found this example for creating threads in the official discord.js guide, but it doesn't work...
const thread = await message.startThread({
name: 'food-talk',
autoArchiveDuration: 60,
reason: 'Needed a separate thread for food',
});
It returns message.startThread is not a function
What is the correct function to do this?
Full Error:
(node:1727) UnhandledPromiseRejectionWarning: TypeError: msg.startThread is not a function
(node:1727) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:1727) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
I think your problem is already solved but here is all you need to do for people who just found this post on google.
npm i discord.js#latest

How to fix 'Error: ENOENT' in node.js if the file and the requirement was deleted?

I recently changed the event handler dor my discord bot and I get this error.
I edited all the files so I don`t get any error but now I get this error and it does not say where the error takes place
(node:9356) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, scandir 'C:\Users\user1\Documents\GitHub\MYSQL_TEST\utils\events'
(node:9356) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:9356) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.```

Discord Bot that check proxies gives a funny error

It keeps returning these errors. I've checked if it was my proxy API - but its not. I believe its an internal error. I've double checked and NPM installed all the dependencies. Still returns this error.
Again, all help is appreciated. Thanks for your time :3
(node:28544) UnhandledPromiseRejectionWarning: Error [INVALID_TYPE]: Supplied options is not an object.
at Message.delete (c::user/example/\Message.js:500:44)
at c:user/example/server.js:27:21
at processTicksAndRejections (internal/process/task_queues.js:93:5)
(node:28544) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:28544) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:28544) UnhandledPromiseRejectionWarning: Error [INVALID_TYPE]: Supplied options is not an object.
at Message.delete (c::user/example/\Message.js:500:44)
at c:\Users\aweso\Downloads\polarcop_discord-master\server.js:32:23
at processTicksAndRejections (internal/process/task_queues.js:93:5)
(node:28544) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
Basing on stack trace you provided, you are passing invalid parameter to message.delete() method. On v12 it takes an object with timeout and/or reason keys, like shown in the documentation. For example, instead of delete(1000) you have to do delete({ timeout: 1000 })
Note however, that not everyone would be able to answer that question without providing more information, like code that gives you that error.

Unhandled promise rejection AVA

I want to use ava for test my code but when I try it I'm getting the following error... I think there is a catch (err) missing...
(node:7640) UnhandledPromiseRejectionWarning: C:\...\TesBoard-db\node_modules\ava\lib\node-arguments.js:9
} catch {
^
(node:7640) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:7640) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Any idea how to resolve this...?
Thanks in advance.
Yes, update Node. <- They recommend Node.js 12.15 in that issue thread.
For future reference, as well as StackOverflow, you want to search the GitHub issues of whatever is throwing or misbehaving, when it is something in the stack.

Node generate image from DOM

I want to generate image or blob from DOM element on nodejs. Since node doesn't have DOM to handle I'm creating one from JSDOM. My initial plan was to use dom-to-image library but it spitting errors:
(node:10384) UnhandledPromiseRejectionWarning: SyntaxError: The string did not match the expected pattern.
at XMLHttpRequest.open (/home/webdev/servers/web/node_modules/jsdom/lib/jsdom/living/xmlhttprequest.js:480:15)
at about:blank:2:5649
at new Promise (<anonymous>)
at j (about:blank:2:5177)
(node:10384) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 3)
(node:10384) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Second plan was to generate canvas by: html2canvas and save it as blob. That also failed by generating:
Error: Not implemented: window.scrollTo
at module.exports (/home/webdev/servers/web/node_modules/jsdom/lib/jsdom/browser/not-implemented.js:9:17)
at /home/webdev/servers/web/node_modules/jsdom/lib/jsdom/browser/Window.js:579:7
at about:blank:6:156607 undefined
Error: Not implemented: HTMLCanvasElement.prototype.getContext (without installing the canvas npm package)
at module.exports (/home/webdev/servers/web/node_modules/jsdom/lib/jsdom/browser/not-implemented.js:9:17)
at HTMLCanvasElementImpl.getContext (/home/webdev/servers/web/node_modules/jsdom/lib/jsdom/living/nodes/HTMLCanvasElement-impl.js:42:5)
at HTMLCanvasElement.getContext (/home/webdev/servers/web/node_modules/jsdom/lib/jsdom/living/generated/HTMLCanvasElement.js:41:47)
at A.value (about:blank:6:43814)
at new A (about:blank:6:134500)
at about:blank:6:63123 undefined
(node:11033) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'scale' of null
(node:11033) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:11033) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
window.scrollTo can be overwritten but canvas is more tricky. There is all sorts of errors including canvas in JSDOM
Rolling fix for it:
https://github.com/jsdom/jsdom/pull/1964
Also I was thinking about using puppeteer as my Virtual DOM since it uses headless chrome but that seems overkill and also can generate errors because you're running separate browser. (I can't even run headless chrome because of errors mentioning no sandbox available).
My question is. Is it even possible to generate image from DOM on server side of nodejs framework?
Project information:
Node version - 10.11.0
Framework - nestjs latest
JSDOM - 12.2.0
html2image - 1.0.0-alpha.12
dom-to-image - 2.6.0

Categories