yaps

command module
v0.0.0-...-de70330 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 17, 2023 License: MIT Imports: 2 Imported by: 0

README

YAlogoS

Yet Another Placeholder Service

YAPS is a server backend which generates placeholder image of any size along with parameters for customization.

Installation

go install github.com/cod3rboy/yaps

Docker Image

docker run -d -p 80:8080 --name yaps-server cod3rboy/yaps

Project Dependencies

  • 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 image package.

Building Project

go build .

Running Server

yaps -hostName localhost -hostPort 8080

Running Tests

go test ./... -v

Command Line Flags

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.

Docker Image Environment Variables

  • PORT: Listener port for yaps server.
  • PATH_PREFIX : Path prefix for all routes.

Usage Guide

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

Examples

Default image (No query parameters)

Default Image

Custom size (?s=200x150)

Custom Size

Yellow background (?s=200x150&b=FFFF00)

Yellow Background

Red text (?s=200x150&b=FFFF00&c=FF0000)

Red Text

Custom text (?s=200x150&b=FFFF00&c=FF0000&t=Hello%20World)

Custom Text

Scaled image (?s=200x100&b=22DB9B&c=FFF&x=1.5)

Scaled Image

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Package config provides the functions to access the configuration values.
Package config provides the functions to access the configuration values.
Package img provides constants, types and functions for automatic image generation.
Package img provides constants, types and functions for automatic image generation.
Package server provides http server setup and handler to serve image generation requests.
Package server provides http server setup and handler to serve image generation requests.
Package utils contains common utility functions used across the application.
Package utils contains common utility functions used across the application.
sliceutils
Package sliceutils contains common utility functions for go slices.
Package sliceutils contains common utility functions for go slices.
stringutils
Package stringutils contains common utility functions for strings.
Package stringutils contains common utility functions for strings.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL