core

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: May 21, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ImageTypes = map[string]vips.ImageType{
	"gif":  vips.ImageTypeGIF,
	"jpeg": vips.ImageTypeJPEG,
	"jpg":  vips.ImageTypeJPEG,
	"png":  vips.ImageTypePNG,
	"tiff": vips.ImageTypeTIFF,
	"webp": vips.ImageTypeWEBP,
	"heif": vips.ImageTypeHEIF,
	"svg":  vips.ImageTypeSVG,
	"psd":  vips.ImageTypePSD,
}
View Source
var Version = "v0.0.0"

Functions

func DecryptAES128GCM

func DecryptAES128GCM(key []byte, base64EncryptedText string) (string, error)

DecryptAES128GCM takes a base64-encoded ciphertext and decrypts it using AES-128-GCM. The input must be encoded as: IV (12 bytes) | Ciphertext | Tag (16 bytes).

func DecryptURL

func DecryptURL(url string) (string, error)

func DecryptURLKey added in v0.7.2

func DecryptURLKey(secretKey string, url string) (string, error)

DecryptURLKey decrypts the given eurl string using a derived AES-128-GCM key.

func EncryptAES128GCM

func EncryptAES128GCM(key []byte, plaintext string) (string, error)

EncryptAES128GCM encrypts the given plaintext using AES-128-GCM with the provided key. The result is base64-encoded and includes IV (12 bytes) | ciphertext | tag (16 bytes).

func EncryptURLKey added in v0.7.2

func EncryptURLKey(secretKey string, url string) (string, error)

func ErrorImage added in v0.6.0

func ErrorImage(color string) (*vips.ImageRef, error)

func NewJpegExportParams

func NewJpegExportParams(options JpegCompression, stripMetadata bool) *vips.JpegExportParams

func NewPngExportParams

func NewPngExportParams(options PngCompression, stripMetadata bool) *vips.PngExportParams

func NewWebpExportParams

func NewWebpExportParams(options WebpCompression, stripMetadata bool) *vips.WebpExportParams

func RegisterImageBackend added in v0.6.0

func RegisterImageBackend(sourceBackend SourceBackend)

Types

type Config

type Config struct {
	BindAddress     string `env:"DIMS_BIND_ADDRESS" envDefault:":8080"`
	DevelopmentMode bool   `env:"DIMS_DEVELOPMENT_MODE" envDefault:"false"`
	DebugMode       bool   `env:"DIMS_DEBUG_MODE" envDefault:"false"`
	LogFormat       string `env:"DIMS_LOG_FORMAT" envDefault:"text"`
	EtagAlgorithm   string

	Timeout
	EdgeControl
	Signing
	Error
	OriginCacheControl
	OutputFormat
	Options
	ImageOutputOptions
}

func ReadConfig

func ReadConfig() *Config

type EdgeControl

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

type Error

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

type FileSource added in v0.6.0

type FileSource struct {
	BaseDir string `env:"DIMS_FILE_BASE_DIR" envDefault:"./resources"`
}

type Image

type Image struct {
	Bytes        []byte         // The downloaded image.
	Size         int            // The original image size in bytes.
	Format       vips.ImageType // 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 FetchImage

func FetchImage(imageSource string, timeout time.Duration) (*Image, error)

type ImageOutputOptions

type ImageOutputOptions struct {
	Jpeg JpegCompression
	Png  PngCompression
	Webp WebpCompression
}

type JpegCompression

type JpegCompression struct {
	Quality            int  `env:"DIMS_JPEG_QUALITY" envDefault:"80"`
	Interlace          bool `env:"DIMS_JPEG_INTERLACE" envDefault:"false"`
	OptimizeCoding     bool `env:"DIMS_JPEG_OPTIMIZE_CODING" envDefault:"true"`
	SubsampleMode      bool `env:"DIMS_JPEG_SUBSAMPLE_MODE" envDefault:"true"`
	TrellisQuant       bool `env:"DIMS_JPEG_TRELLIS_QUANT" envDefault:"false"`
	OvershootDeringing bool `env:"DIMS_JPEG_OVERSHOOT_DERINGING" envDefault:"false"`
	OptimizeScans      bool `env:"DIMS_JPEG_OPTIMIZE_SCANS" envDefault:"false"`
	QuantTable         int  `env:"DIMS_JPEG_QUANT_TABLE" envDefault:"3"`
}

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 {
	Default  string   `env:"DIMS_DEFAULT_OUTPUT_FORMAT"`
	Excluded []string `env:"DIMS_EXCLUDED_OUTPUT_FORMATS"`
}

type PngCompression

type PngCompression struct {
	Quality     int  `env:"DIMS_PNG_QUALITY" envDefault:"80"`
	Interlace   bool `env:"DIMS_PNG_INTERLACE" envDefault:"false"`
	Compression int  `env:"DIMS_PNG_COMPRESSION" envDefault:"4"`
}

type S3

type S3 struct {
	Region string `env:"DIMS_S3_REGION" envDefault:""`
	Bucket string `env:"DIMS_S3_BUCKET" envDefault:""`
	Prefix string `env:"DIMS_S3_PREFIX" envDefault:""`
}

type Signer added in v0.6.0

type Signer interface {
	SignedUrl() string
}

type Signing

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

type Source added in v0.6.0

type Source struct {
	Default string   `env:"DIMS_DEFAULT_SOURCE_BACKEND" envDefault:"http"`
	Allowed []string `env:"DIMS_ALLOWED_SOURCE_BACKENDS" envDefault:"http"`
}

type SourceBackend added in v0.6.0

type SourceBackend interface {
	Name() string
	CanHandle(imageSource string) bool
	FetchImage(imageSource string, timeout time.Duration) (*Image, error)
}

type StatusError

type StatusError struct {
	StatusCode int
	Message    string
}

func NewStatusError

func NewStatusError(statusCode int, message string) *StatusError

func (*StatusError) Error

func (e *StatusError) Error() string

type Timeout

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

type WebpCompression

type WebpCompression struct {
	Quality         int    `env:"DIMS_WEBP_QUALITY" envDefault:"80"`
	Compression     string `env:"DIMS_WEBP_COMPRESSION" envDefault:"lossy"`
	ReductionEffort int    `env:"DIMS_WEBP_REDUCTION_EFFORT" envDefault:"4"`
}

Jump to

Keyboard shortcuts

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