https://github.com/monstercat/asset-delivery
A self hosted alternative to Cloudflare Images.
https://github.com/monstercat/asset-delivery
image-resizing
Last synced: 5 months ago
JSON representation
A self hosted alternative to Cloudflare Images.
- Host: GitHub
- URL: https://github.com/monstercat/asset-delivery
- Owner: monstercat
- License: mit
- Created: 2018-04-06T23:09:14.000Z (about 8 years ago)
- Default Branch: main
- Last Pushed: 2022-10-17T21:19:57.000Z (over 3 years ago)
- Last Synced: 2024-06-21T16:56:08.792Z (almost 2 years ago)
- Topics: image-resizing
- Language: Go
- Homepage:
- Size: 37.1 KB
- Stars: 2
- Watchers: 5
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Asset Delivery
Delivers resized assets (images) in response to HTTP requests. It contains two parts:
- Delivery server
- Resizing routine
## Delivery Server
The delivery server attempts to find an existing resized file from a storage location. If the resized file is found it
returns the resized file. Otherwise, it will deliver the original file and send an instruction to create a resized
version of said file.
### HTTP Request
Each request needs to have the following as URL parameters:
- width
- location
- encoding (e.g., webp, jpeg, png)
For example, if you want a version of https://host/path with width=100 and encoding=webp, the resulting request would be
`https://[host]?width=100&url=https://host/path&encoding=webp`
### Environment Variables
- **BUCKET**: GCP Storage bucket name
- **HOST**: GCP Storage host (optional). You can fill this in if an emulator is being used.
### Command-Line Arguments
- **ADDRESS**: Address to bind to. Defaults to: 0.0.0.0:80
- **credentials**: The location of the Google JWT file.
- **allowedHosts**: A comma separated list of domain hosts. This is used to filter requests by the host in the "urL" query param (above). Only "url"s that contain one of the provided hosts will be resized. An empty value allows any.
- **project-id**: Google Project ID (for logging & pubsub)
### TODO:
- Externalize the PubSub topic in an environment variable
## Resizing
Resizing is done through `GcfResize` function which is meant to be run as a Google Cloud Function.
### Environment Variables
- **PROJECTID**: Google Project ID (used for logging)
- **BUCKET**: GCP Storage bucket name