bostrom / text-to-image

Converts text as a string to an image containing that text.
ISC License
108 stars 40 forks source link

Text rotation #63

Open ahmedalnaqaa opened 4 years ago

ahmedalnaqaa commented 4 years ago

Hello Everyone,

Is there a solution for rotating the text?

Thanks

bostrom commented 4 years ago

Hello @ahmedalnaqaa. There's no built in solution for text rotation at the moment, and I myself don't have much time to look into it, but I'm happy to accept PRs 🙂

ronaldaug commented 3 years ago

I try to rotate with jimp and it does work with just a few steps. However, it rotates the whole image instead of text.

const textToImage = require('text-to-image');
const Jimp = require('jimp');

async function rotateImage(img,name) {
    const image        = await Jimp.read(img);
    const rotate_angle = 10;
    image.rotate(rotate_angle).write('hello/'+name+'.png');
}

textToImage.generate('Hello world').then(datauri=>{
    let buff    = datauri.substring(22);
    const image = Buffer.from(buff,'base64');
    rotateImage(image,"filename");
})