dims

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CmykIccProfile []byte = []byte{}/* 557164 elements not displayed */
View Source
var RgbIccProfile []byte = []byte{}/* 560 elements not displayed */

Functions

func HandleDimsStatus

func HandleDimsStatus(config EnvironmentConfig, debug bool, dev bool, w http.ResponseWriter, r *http.Request)

func Handler

func Handler(kernel Kernel, config Config, w http.ResponseWriter, r *http.Request)

Types

type Command

type Command struct {
	Name      string
	Args      string
	Operation Operation
}

type Config

type Config struct {
	DevelopmentMode bool
	DebugMode       bool
	EtagAlgorithm   string
	EnvironmentConfig
}

type EdgeControl

type EdgeControl struct {
	DownstreamTtl int `env:"DIMS_EDGE_CONTROL_DOWNSTREAM_TTL" envDefault:"0"`
}

type Error

type Error struct {
	Image      string `env:"DIMS_ERROR_IMAGE" envDefault:""`
	Background string `env:"DIMS_ERROR_BACKGROUND" envDefault:"#5ADAFD"`
}

type Image

type Image struct {
	Bytes        []byte // The downloaded image.
	Size         int    // The original image size in bytes.
	Format       string // The original image format.
	Status       int    // The HTTP status code of the downloaded image.
	CacheControl string // The cache headers from the downloaded image.
	EdgeControl  string // The edge control headers from the downloaded image.
	LastModified string // The last modified header from the downloaded image.
	Etag         string // The etag header from the downloaded image.
}

func ImageFromMagickWand added in v0.2.0

func ImageFromMagickWand(mw *imagick.MagickWand) Image

type Kernel

type Kernel interface {
	ValidateSignature() bool
	FetchImage() error
	ProcessImage() (string, []byte, error)
	SendHeaders(w http.ResponseWriter)
	SendImage(w http.ResponseWriter, status int, imageType string, imageBlob []byte) error
	SendError(w http.ResponseWriter, status int, message string)
}

type Operation

type Operation func(mw *imagick.MagickWand, args string) error

type Options

type Options struct {
	StripMetadata      bool `env:"DIMS_STRIP_METADATA" envDefault:"true"`
	IncludeDisposition bool `env:"DIMS_INCLUDE_DISPOSITION" envDefault:"false"`
}

type OriginCacheControl

type OriginCacheControl struct {
	UseOrigin bool `env:"DIMS_CACHE_CONTROL_USE_ORIGIN" envDefault:"false"`
	Min       int  `env:"DIMS_CACHE_CONTROL_MIN" envDefault:"0"`
	Max       int  `env:"DIMS_CACHE_CONTROL_MAX" envDefault:"0"`
	Default   int  `env:"DIMS_CACHE_CONTROL_DEFAULT" envDefault:"31536000"`
	Error     int  `env:"DIMS_CACHE_CONTROL_ERROR" envDefault:"60"`
}

type OutputFormat

type OutputFormat struct {
	OutputFormat string   `env:"DIMS_OUTPUT_FORMAT"`
	Exclude      []string `env:"DIMS_OUTPUT_FORMAT_EXCLUDE"`
}

type Request

type Request struct {
	Id                     string    // The hash of the request -> hash(clientId + commands + imageUrl).
	Signature              string    // The signature of the request.
	Config                 Config    // The global configuration.
	ClientId               string    // The client ID of this request.
	ImageUrl               string    // The image URL that is being manipulated.
	SendContentDisposition bool      // The content disposition of the request.
	Commands               []Command // The commands (resize, crop, etc).
	Error                  bool      // Whether the error image is being served.
	SourceImage            Image     // The source image.
}

func (*Request) FetchImage

func (r *Request) FetchImage() error

FetchImage downloads the image from the given URL.

func (*Request) ProcessImage

func (r *Request) ProcessImage() (string, []byte, error)

ProcessImage will execute the commands on the image.

func (*Request) SendError

func (r *Request) SendError(w http.ResponseWriter, status int, message string)

func (*Request) SendHeaders

func (r *Request) SendHeaders(w http.ResponseWriter)

func (*Request) SendImage

func (r *Request) SendImage(w http.ResponseWriter, status int, imageFormat string, imageBlob []byte) error

type Signing

type Signing struct {
	SigningKey    string `env:"DIMS_SIGNING_KEY,notEmpty"`
	EtagAlgorithm string
}

type Timeout

type Timeout struct {
	Download int `env:"DIMS_DOWNLOAD_TIMEOUT" envDefault:"3000"`
}

Jump to

Keyboard shortcuts

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