core

package
v0.0.0-...-1abe31c Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2023 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const AppName = "Img Opt"

Variables

View Source
var ErrJobLimitReached = errors.New("Job Limit Has Been Reached")
View Source
var FormatNameToImageType = map[string]vips.ImageType{
	"jpeg": vips.ImageTypeJPEG,
	"png":  vips.ImageTypePNG,
	"webp": vips.ImageTypeWEBP,
	"avif": vips.ImageTypeAVIF,
}
View Source
var ImageTypeToFormatName = map[vips.ImageType]string{
	vips.ImageTypeJPEG: "jpeg",
	vips.ImageTypePNG:  "png",
	vips.ImageTypeWEBP: "webp",
	vips.ImageTypeAVIF: "avif",
}
View Source
var ImageTypeToMime = map[vips.ImageType]string{
	vips.ImageTypeJPEG: "image/jpeg",
	vips.ImageTypePNG:  "image/png",
	vips.ImageTypeWEBP: "image/webp",
	vips.ImageTypeAVIF: "image/avif",
}
View Source
var UnknownImageTypeErr = errors.New("unknown image type")
View Source
var UnsupportedImageTypeErr = errors.New("unsupported image type")

Functions

func CreateETagFromFile

func CreateETagFromFile(filePath string) (string, error)

func DetermineImageType

func DetermineImageType(imagePath string) (vips.ImageType, error)

func DoesFileExist

func DoesFileExist(filePath string) (bool, error)

func ReadWholeFile

func ReadWholeFile(filePath string) ([]byte, error)

Types

type JobLimiter

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

func NewJobLimiter

func NewJobLimiter(max uint) *JobLimiter

func (*JobLimiter) AddJob

func (jc *JobLimiter) AddJob() error

func (*JobLimiter) Jobs

func (jc *JobLimiter) Jobs() uint

func (*JobLimiter) RemoveJob

func (jc *JobLimiter) RemoveJob()

type NonStandardSupport

type NonStandardSupport struct {
	WEBP bool
	AVIF bool
}

func NonStandardFromAcceptHeader

func NonStandardFromAcceptHeader(headerContent string) NonStandardSupport

type OptimiseJob

type OptimiseJob struct {
	FullPath string
	OutType  vips.ImageType
	MaxWidth *int
	Quality  int
}

func (*OptimiseJob) Optimise

func (job *OptimiseJob) Optimise() ([]byte, error)

Jump to

Keyboard shortcuts

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