An Azure Function App to encode and decode images using the the BlurHash algorithm.
Demo and API is available at blurhash.dholmes.co.uk. Read the Blog post for more information and related posts.
Remotes for this repo:
- Decodes a BlurHash and return a jpeg to the specified dimensions
- Request URL GET:
/api/v1/blur-hash
- URL Params:
- blurhash: blurhash for the the image (required)
- width: Width of the decoded image (required)
- height: Height of the decoded image (required)
- URL Params:
Returns a jpg based on the URL params if the BlurHash string is valid.
Example error response (400):
{
"error": true,
"message": "The blurhash is invalid - blurhash length mismatch: length is 18 but it should be 28"
}
- Encodes an image and returns a BlurHash string
- Request URL POST:
/api/v1/blur-hash
- Body Params:
- imageUrl: URL for the image (required)
- Body Params:
Returns BlurHash'd image if the imageUrl
is valid and publicly accessible.
Example request body:
{
"imageUrl": "https://c1.wallpaperflare.com/preview/102/822/554/beach-north-sea-sea-sunset.jpg"
}
Example error response (404):
{
"error": true,
"message": "imageUrl <imageUrl> could not be loaded"
}
- Health check route
- Request URL GET:
/api/v1/health-check
Used by monitoring to check system health.
Example response:
{
"error": false,
"message": "Service is available"
}
- An installation of Node.js v18.12.1 (npm v8.19.2)
- An installation of Azure Functions Core Tools v4
- An installation of VSCode with the following extensions:
- Copy ./local.settings-template.json to
./local.settings.json
npm i
: Installs dependenciesnpm run start:dev
: Starts the local DEV environment- Press
CTRL+c
: Stops the local DEV environment
Command | Description |
---|---|
npm start |
Starts the Function App in Azure func start |
npm start:dev |
Starts a local dev environment by running npm start and npm run watch concurrently |
npm run build |
Create a build tsc |
npm run watch |
Watch and create a build tsc tsc -w |
npm run audit |
Runs npm audit --production --audit-level=critical to check for known vulnerabilities |
npm run lint |
Run eslint eslint --max-warnings=0 --ext=ts,json ./ |
npm run lint:fix |
Run eslint with fix arg eslint --max-warnings=0 --fix --ext=ts,json ./ |
- Des Holmes: Technical Leadership & Product Development
- About Blog
- Skills & knowledge: Technical Leadership, Technical Direction, Technical Delivery, Product Development, SaaS, DevOps, Azure Public Cloud
- Job Titles: CTO, VP Engineering, Head of DevOps, Technical Product Owner
- Example Projects: Development standards, DevOps, CI/CD, React, docker, Cost Management
- woltapp/blurhash algorithm
- Add base64 encoded property to
POST: /api/v1/blur-hash
response