core

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: May 16, 2025 License: Apache-2.0 Imports: 16 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,
}

ImageTypes defines the various image types supported by govips

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(secretKey string, base64Eurl string) (string, error)

DecryptURL 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 EncryptURL

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

func EncryptionKey

func EncryptionKey(secretKey string) []byte

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

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"`
	EtagAlgorithm   string

	Timeout
	EdgeControl
	Signing
	Error
	OriginCacheControl
	OutputFormat
	Options
	ImageOutputOptions
	S3
}

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 {
	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 FetchImage

func FetchImage(imageUrl 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 {
	OutputFormat string   `env:"DIMS_OUTPUT_FORMAT"`
	Exclude      []string `env:"DIMS_OUTPUT_FORMAT_EXCLUDE"`
}

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 {
	Bucket string `env:"DIMS_S3_BUCKET" envDefault:""`
	Prefix string `env:"DIMS_S3_PREFIX" envDefault:""`
}

type Signing

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

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