Deno.js Emoji Module to Write Emoji Images From Canvas and Save it as PNG Image File Using TypeScript Full Project For Beginners

 

 

Emoji Canvas

 

 

An easy to use module to write text with parsed emojis (supports discord emojis too) in deno-canvas!

 

 

 

emoji.ts

 

 

import Canvas, { dataURLtoFile, loadImage } from 'https://deno.land/x/canvas@v1.1.3/mod.ts';
import fillTextWithEmoji from "https://raw.githubusercontent.com/Scientific-Guy/emoji-canvas/master/mod.ts";

const canvas = Canvas.MakeCanvas(200, 200);
const ctx = canvas.getContext('2d');

ctx.fillRect(0, 0, 800 - 20, 800 - 20);
ctx.fillStyle = 'white';
ctx.font = '30px monospace';

await fillTextWithEmoji(ctx, 'Hi 🤣', 10, 40); 
Deno.writeFileSync("Test.png", dataURLtoFile(canvas.toDataURL()))

 

 

Now to run this file you need to run the below command as shown below

 

 

deno run --allow-net --allow-write emoji.ts

 

 

After this you will find an image file of emoji like this

 

 

Leave a Reply