apiholdit

package module
v0.0.0-...-d417d1f Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2017 License: MIT Imports: 12 Imported by: 0

README

apiholdit

License ReportCard

Table of contents

Introduction

APIholdit is a drop-in and easy to deploy microservice who exposes an HTTP API you can use to generate placeholder images with a desired text, automatically centered and scaled.

For example:

psh screenshot

User Documentation

The main entry point for the REST API is the following URL:

http://<host>:<port>/i
URL Parameters

This URL accept the following parameters:

Width

width of the placeholder image in pixels.

By default is 640 pixels.

Height

height of the placeholder image in pixels.

By default is 480 pixels.

Text

text defines the placeholder text that will appear autoscaled and centered on the placeholdwr image.

This text should be encoded to allow special characters.

By default is the string Placeholder.

Background color

bgcolor sets the background color to be used to render the placeholder image.

By default is the color called Silver from the FlatUIColors color palette. And its code is #bdc3c7.

Foreground color

fgcolor sets the foreground color, or the color being used to draw the text on the placeholder image.

By default is the color called Midnight Blue from the FlatUIColors color palette. And its code is #2c3e50.

Examples

Here are a few eamples using the previous defined API:

URL Placeholdwer
http://example.com/i?width=320&height=200 psh screenshot
http://example.com/i?width=320&height=200&text=placeholder-text psh screenshot
http://example.com/i?width=320&height=200&text=placeholder-text&bgcolor=c0392b&fgcolor=2980b9 psh screenshot

Developer Documentation

Deployment

You can also deploy APIHoldit on Heroku with this one click button:

Deploy

Continuous integration

Tests
  • Develop: CircleCI
  • Master: CircleCI
Coverage
  • Develop: Coverage Status
  • Master: Coverage Status

License

(The MIT License)

Copyright (c) 2017 apiholdit Authors.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Documentation

Index

Constants

View Source
const (
	// DefaultServerAddress is the default hostname where the server is going
	// to be started and listening.
	DefaultServerAddress = "localhost"

	// DefaultServerPort is the default port number where the server is going
	// to be started and listening.
	DefaultServerPort = "8080"

	// DefaultWidth is the default width of the image placeholder.
	DefaultWidth = 640

	// DefaultHeight is the default height of the image placeholder.
	DefaultHeight = 480

	// DefaultDPI is the default DPI value for the image placeholder.
	DefaultDPI = 72.00

	// DefaultMarginRatio is the default margin ratio to be used to render
	// the text on the image placeholder.
	//
	// This percentage margin will be applied to both four inner margin of the
	// image bounds.
	DefaultMarginRatio = 0.2

	// DefaultMaxFontSize is the maximum size of the font that will be used to
	// render the placeholder text.
	DefaultMaxFontSize = 512.00

	// DefaultText is the default text to be rendered.
	DefaultText = "Placeholder"

	// DefaultFontPath ...
	DefaultFontPath = "data/fonts/Roboto-Black.ttf"
)

Variables

View Source
var (
	// DefaultBackgroundColor : Silver #bdc3c7
	// http://flatuicolors.com/
	DefaultBackgroundColor = &color.RGBA{189, 195, 199, 255}

	// DefaultForegroundColor : Midnight Blue #2c3e50
	// http://flatuicolors.com/
	DefaultForegroundColor = &color.RGBA{44, 62, 80, 255}
)

Functions

This section is empty.

Types

type PlaceHolder

type PlaceHolder struct {
	Width           int
	Height          int
	Text            string
	MarginRatio     float64
	BackgroundColor *color.RGBA
	ForegroundColor *color.RGBA
	Canvas          *image.RGBA
}

PlaceHolder ...

func NewPlaceHolder

func NewPlaceHolder() *PlaceHolder

NewPlaceHolder ...

func (*PlaceHolder) EncodeGIF

func (p *PlaceHolder) EncodeGIF(options *gif.Options) (*bytes.Buffer, error)

EncodeGIF ...

func (*PlaceHolder) EncodeJPEG

func (p *PlaceHolder) EncodeJPEG(options *jpeg.Options) (*bytes.Buffer, error)

EncodeJPEG ...

func (*PlaceHolder) EncodePNG

func (p *PlaceHolder) EncodePNG() (*bytes.Buffer, error)

EncodePNG ...

func (*PlaceHolder) Render

func (p *PlaceHolder) Render() error

Render ...

func (*PlaceHolder) SetBackgroundColor

func (p *PlaceHolder) SetBackgroundColor(bgcolor string) error

SetBackgroundColor ...

func (*PlaceHolder) SetForegroundColor

func (p *PlaceHolder) SetForegroundColor(fgcolor string) error

SetForegroundColor ...

func (*PlaceHolder) SetHeight

func (p *PlaceHolder) SetHeight(height int) error

SetHeight sets the height of the placeholder and regenerates the canvas with the new size.

func (*PlaceHolder) SetText

func (p *PlaceHolder) SetText(text string) error

SetText ...

func (*PlaceHolder) SetWidth

func (p *PlaceHolder) SetWidth(width int) error

SetWidth sets the width of the placeholder and regenerates the canvas with the new size.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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