Multiple Line Breaks & Detecting Rollover
See original GitHub issueWhen creating a Jimp and adding text, I want to add multiple lines like so:
async function modifyImage() {
const img = await global.jimp.read("red_black_bg.png");
const font = await global.jimp.loadFont("font.fnt");
img.print(font, 10, 380, 'I Know What You Did Last Summer', 1920); // text 1
img.print(font, 10, 500, 'Shawn Mendes & Camila Cabello', 1920); // text 2
img.getBuffer(global.jimp.MIME_PNG, function(err, buffer) {
if (err) throw new Error(error);
else m.channel.send({files: [buffer]});
});
}
The issue is, when text 1 wraps, it overlaps with text 2. Is it possible to detect this at all? I’ve tried inserting line-breaks into the first text but that doesn’t seem to work.
Here’s an example:
async function modifyImage() {
const img = await global.jimp.read("red_black_bg.png");
const font = await global.jimp.loadFont("font.fnt");
img.print(font, 10, 380, 'I Know What You Did Last Summer ABCDEFGHIJKLMNOP', 1920); // text 1
img.print(font, 10, 500, 'Shawn Mendes & Camila Cabello', 1920); // text 2
img.getBuffer(global.jimp.MIME_PNG, function(err, buffer) {
if (err) throw new Error(error);
else m.channel.send({files: [buffer]});
});
}
In the example above, the “ABCDEFGHIJKLMNOP” overlaps the text 2 as seen in the result:
I’ve pulled this off using Node.js v9.2.0
using npm 5.5.1
. I don’t know any other languages so… that’s all I can give you.
Issue Analytics
- State:
- Created 6 years ago
- Comments:9
Top Results From Across the Web
How can I do a line break (line continuation) in Python?
Long lines can be broken over multiple lines by wrapping expressions in parentheses. These should be used in preference to using a backslash...
Read more >Use Line Breaks, Paragraph Ends, and Tabs ...
When including literal text strings in computation scripts, you can have HotDocs merge line breaks, paragraph ends, and tabs in the answer.
Read more >How can I handle the millis() rollover?
Short answer: do not try to “handle” the millis rollover, write rollover-safe code instead. Your example code from the tutorial is fine.
Read more >Identifying Head-and-Shoulders Patterns in Stock Charts
Identifying so-called head-and-shoulders patterns can be tricky but profitable. ... head-and-shoulder when the stock breaks higher through the neckline.
Read more >Cluster fault detection | Elasticsearch Guide [8.5]
When a node leaves the cluster, logs for the elected master include a message like this (with line breaks added for clarity):.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
apologies for not responding, honestly it’s been so long I forgot about the issue and I’m not even attempting this anymore lol
I have an issue with the text wrapping not still working with latest jimp version. I have an open issue here, https://github.com/oliver-moran/jimp/issues/710 but no feedback on it yet