Versions in this module Expand all Collapse all v1 v1.1.1 Mar 28, 2022 Changes in this version type Config + MaxUploadSize int v1.1.0 Dec 29, 2021 Changes in this version + const ImageFitContain + const ImageFitCover + const ImageFitDefault + const ImageTypeJPEG + const ImageTypeWEBP + const MaxImagesPerFolder + var ErrInvalidImageFit = errors.New("invalid image fit") + var ErrNoDefaultImage = errors.New("no default image was provided") + var ErrUnsupportedImage = errors.New("unsupported image format") + func ContainInResolution(width, height, w, h int) (int, int) + func GetImageSize(image []byte) (w int, h int, err error) + func RunMigrations(db *sql.DB) error + type Config struct + Addr string + Database struct{ ... } + DeletedDir string + RootUploadsDir string + func UnmarshalConfigFile(file string) (*Config, error) + type DBImage struct + AverageColor RGB + Copies []*ImageCopy + CreatedAt time.Time + DeletedAt *time.Time + FolderID int + Height int + ID luid.ID + IsDeleted bool + MaxHeight int + MaxWidth int + Size int + Type ImageType + URL string + URLs []string + UploadedSize int + Width int + func DeleteImage(db *sql.DB, ID luid.ID, rootDir, deletedDir string) (*DBImage, error) + func GetImage(db *sql.DB, ID luid.ID) (*DBImage, error) + func SaveImage(db *sql.DB, buf []byte, copies []SaveImageArg, rootDir string) (*DBImage, error) + func (i *DBImage) GenerateURLs() + type ImageCopy struct + Height int + ImageFit ImageFit + MaxHeight int + MaxWidth int + Size int + Width int + func (c ImageCopy) Filename(imageID string) string + type ImageFit string + func (i *ImageFit) UnmarshalText(text []byte) error + type ImageSize struct + Height int + Width int + func ToJPEG(image []byte, maxWidth, maxHeight int, fit ImageFit) ([]byte, ImageSize, error) + func (s *ImageSize) UnmarshalText(text []byte) error + func (s ImageSize) MarshalText() ([]byte, error) + func (s ImageSize) String() string + type ImageType string + type RGB struct + B int + G int + R int + func AverageColor(img image.Image) RGB + type SaveImageArg struct + ImageFit ImageFit + IsDefault bool + MaxHeight int + MaxWidth int + type Server struct + func NewServer(db *sql.DB, c *Config) *Server + func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) v1.0.0 Nov 18, 2021