Yet Another Placeholder Service
YAPS is a server backend which generates placeholder image of any size along with parameters for customization.
go install github.com/cod3rboy/yaps
docker run -d -p 80:8080 --name yaps-server cod3rboy/yaps
- go-webpbin - For webp format encoding.
- gg - Go graphics library.
- gofiber - Web framework for golang.
- freetype - Font rendering library.
- iniflags - Library to load flags from ini configuration files.
- image - Supplementary library to standard
imagepackage.
go build .
yaps -hostName localhost -hostPort 8080
go test ./... -v
| Flag | Description | Default |
|---|---|---|
hostName |
Server host name to use. | localhost |
hostPort |
Server port number to use. | 8080 |
pathPrefix |
Prefix path for all routes. | / |
allowMethods |
Comma-separated http methods to allow for CORS. | GET,PUT,PATCH,POST |
allowOrigins |
Commad-separated whitelisted origins for CORS. | example.com,foo.com,bar.com or * |
config |
Path to ini configuration file. |
PORT: Listener port for yaps server.PATH_PREFIX: Path prefix for all routes.
Once the server is up and running (at localhost:8080 for example) then you can send GET request to generate and receive placeholder images. The request path determines the image format and query parameters are used to customize image -
| Path | Image Format |
|---|---|
| /png | PNG Image |
| /jpg | JPG Image |
| /jpeg | JPEG Image |
| /tiff | TIFF Image |
| /webp | WEBP Image |
| Query Parameter | Description | Example |
|---|---|---|
| s | Image dimensions (width x height) | 200x100 |
| b | Background color in hexadecimal digits | F3FFEA or FA3 |
| c | Text color in hexadecimal digits | F3FFEA or FA3 |
| t | Text to display in the image | Hello World |
| x | Scaling factor for width and height | 2 or 1.5 |
Default image (No query parameters)
Custom size (?s=200x150)
Yellow background (?s=200x150&b=FFFF00)
Red text (?s=200x150&b=FFFF00&c=FF0000)
Custom text (?s=200x150&b=FFFF00&c=FF0000&t=Hello%20World)
Scaled image (?s=200x100&b=22DB9B&c=FFF&x=1.5)





