Depending on the library that you use to create the image, you should be able to res.end(image, 'binary'); Remember to include the correct Content-Type header.
If you do not want to generate a file every time you can write the file to disk, store it in the key / value repository, relational database, etc ... and check / maintain it if it has already been created before go through the creation procedures.
source share