imagehost

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2022 License: MIT Imports: 37 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// CroppingModeExact crops an image exactly to given dimensions
	CroppingModeExact = "e"
	// CroppingModeAll crops an image so that all of it is displayed in a frame of at most given dimensions
	CroppingModeAll = "a"
	// CroppingModePart crops an image so that it fills a frame of given dimensions
	CroppingModePart = "p"
	// CroppingModeKeepScale crops an image so that it fills a frame of given dimensions, keeps scale
	CroppingModeKeepScale = "k"

	GravityNorth     = "n"
	GravityNorthEast = "ne"
	GravityEast      = "e"
	GravitySouthEast = "se"
	GravitySouth     = "s"
	GravitySouthWest = "sw"
	GravityWest      = "w"
	GravityNorthWest = "nw"
	GravityCenter    = "c"

	FilterGrayScale = "grayscale"

	DefaultScale        = 1
	DefaultCroppingMode = CroppingModeExact
	DefaultGravity      = GravityNorthWest
	DefaultFilter       = "none"

	MaxDimension = 10000
)

Variables

View Source
var Module = module.Module{
	ModuleName:    "image",
	ModuleVersion: "1.1.0",
	ModuleConfig:  imageConfig,
	ModuleDepends: []string{
		"user",
	},
	ModuleEnv: map[string]any{
		"cache.evict": onEvict,
	},
	ModuleExport: map[string]any{},
	ModulePerm: map[string]string{
		"image.upload": "上传图片",
		"image.view":   "查看图片",
		"image.custom": "处理图片",
	},
	EntryPoint: entry,
}

Functions

This section is empty.

Types

type FontMetrics

type FontMetrics struct {
	// contains filtered or unexported fields
}

FontMetrics defines font metrics for a Text struct as rounded up integers

type Params

type Params struct {
	Width    int
	Height   int
	Scale    int
	Cropping string
	Gravity  string
	Filter   string
}

Params is a struct of parameters specifying an image transformation

func (Params) ToString

func (p Params) ToString() string

ToString turns parameters into a unique string for each possible assignment of parameters

func (Params) WithScale

func (p Params) WithScale(scale int) Params

WithScale returns a copy of a Params struct with the scale set to the given value

type Text

type Text struct {
	// contains filtered or unexported fields
}

Text specifies a text overlay to be applied to an image

type TextInfo

type TextInfo struct {
	Content  string  `mapstructure:"content" yaml:"content"`
	Gravity  string  `mapstructure:"gravity" yaml:"gravity"`
	FontPath string  `mapstructure:"font"    yaml:"font"`
	X        int     `mapstructure:"x-pos"   yaml:"x-pos"`
	Y        int     `mapstructure:"y-pos"   yaml:"y-pos"`
	Size     int     `mapstructure:"size"    yaml:"size"`
	Color    string  `mapstructure:"color"   yaml:"color"`
	Alpha    float64 `mapstructure:"alpha"   yaml:"alpha"`
}

type Transformation

type Transformation struct {
	Hash string
	// contains filtered or unexported fields
}

Transformation specifies parameters and a watermark to be used when transforming an image

type TransformationInfo

type TransformationInfo struct {
	Name    string     `mapstructure:"name"    yaml:"name"`
	Params  string     `mapstructure:"params"  yaml:"params"`
	Texts   []TextInfo `mapstructure:"texts"   yaml:"texts"`
	Default bool       `mapstructure:"default" yaml:"default"`
	Eager   bool       `mapstructure:"eager"   yaml:"eager"`
}

TransformationInfo for config parsing.

func (*TransformationInfo) ToTransformation

func (t *TransformationInfo) ToTransformation() *Transformation

Jump to

Keyboard shortcuts

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