This repository contains an Azure Function that generates a PNG image with the given hex code as the background color.
To get started, you will need to have Node.js 18 and npm 8 installed on your machine.
- Clone the repository and navigate to the directory:
git clone https://github.com/your-username/hex-to-png.git
cd hex-to-png
- Install the required dependencies:
npm install
- Initialize the Azure Function project:
npx func init
- In one terminal, run the TypeScript compiler in watch mode:
npm run watch
- In another terminal, run the function locally:
npm start
The function should now be running locally on your machine. You can use an HTTP trigger to send a request to the function and receive a response with the generated PNG image.
To use the function, send a GET request to the following URL, where c0ffee
is the hex code without a hash tag and 500x600
are the width and height of the image in pixels:
http://localhost:7071/api/hex-to-png/c0ffee/500x600.png
The response will be a PNG image with the specified hex code as the background color and the specified dimensions.
To deploy the function to Azure, you will need to have an Azure account and create a new Function App. For more information on how to do this, see the Azure Functions documentation.
Once you have a Function App set up, you can deploy the function to Azure using the Azure Functions Core Tools.
- In the terminal, navigate to the directory containing the function code.
- Run the following command to login to your Azure account:
az login
- Run the following command to deploy the function to your Function App:
func azure functionapp publish [your-function-app-name]
Replace [your-function-app-name] with the name of your Function App. For Flugger staff, find existing deployment in the color resource group.
The function should now be deployed and available at the following URL, where c0ffee is the hex code without a hash tag and 500x600 are the width and height of the image in pixels:
https://your-function-app-name.azurewebsites.net/api/hex-to-png/c0ffee/500x600.png
The response will be a PNG image with the specified hex code as the background color and the specified dimensions.
Developed by Luke with 🎨.