Last active
February 20, 2020 08:01
-
-
Save ZainWWF/5345eaef389341780435ec3eb316f02c to your computer and use it in GitHub Desktop.
Cloud function request with param and returns a png file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { createCanvas } from 'canvas' | |
export const signatureImage = functions.https.onRequest((request, response) => { | |
console.log(request.query.name) | |
if(!request.query.name || request.query.name.length === 0) | |
response.status(500).send("require a name") | |
const canvas = createCanvas(200, 200) | |
const ctx = canvas.getContext('2d') | |
ctx.font = '30px Impact' | |
ctx.rotate(0.1) | |
ctx.fillText(request.query.name, 50, 100) | |
response.send(canvas.toBuffer("image/png")); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment