azureog

package module
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2021 License: GPL-3.0 Imports: 8 Imported by: 0

README

Azure OG

I stumbled across DevsQuotesPrinter and loved the idea so much I had to build my own.

I modified the code to accept the title and font size as query parameters, with defaults if they aren't sent.

The app has a command-line interface as well as an Azure Function. The cli tool accepts parameters to control the title and font size. The Azure Function accepts the same parameters as a query string.

CLI

make build-cli
make run TITLE="I'm so social"

Details :

./dist/azureog --help                                                                                   
Usage of ./dist/azureog:
  -bgImg string
        image to use as background (default "assets/og-standard.png")
  -fontPath string
        filename of the ttf font (default "assets/FiraSans-Light.ttf")
  -fontSize float
        font fontSize in points (default 140)
  -output string
        output path for the resulting image (default "og-image.png")
  -title string
        text to print on the image (default "Nothing To See Here, Move Along")

Azure Functions

I followed this handy reference to build a Go app as a custom Azure Function deployed on the Linux Consumption plan. Costs should be trivial.

Make it yours!

To make one for yourself, replace assets/og-standard.png with a background of your own creation. Use the same file name or modify the code to reflect your new background image's file name.

Then you can build and use locally or deploy to Azure Functions to have your very own OG Social Image Sharing app.

License

GPL v3

Origins and Credits

Inspired by, and much code from DevQuotesPrinter - GPL v3 Licensed.

Github Action

There is a github action available.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Save

func Save(img image.Image, path string) error

func TextOnImg

func TextOnImg(request Request) (image.Image, error)

TextOnImg given a path to an image, a font & size and a text it will return an Image with the given text printed in the ~middle of the image

Types

type Assets

type Assets struct {
	BgImgPath string
	FontPath  string
	FontSize  float64
}

func (*Assets) Serve

func (a *Assets) Serve(w http.ResponseWriter, r *http.Request)

Serve writes on the image referenced on Assets.BgImgPath with the font set on Assets.FontPath and the size Assets.FontSize the text present on the http.Request.

type Request

type Request struct {
	BgImgPath string
	FontPath  string
	FontSize  float64
	Text      string
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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