image

package
v0.0.0-...-b95d14b Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2024 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package image provides an image store and resizer. It depends on convert (from imagemagick). Uploaded files are stored in original, but not served via HTTP.

store := image.Store{
    CacheDir: filepath.Join(os.Getenv("CACHE_DIRECTORY"), "imagedir"),
    Dir:      filepath.Join(os.Getenv("STATE_DIRECTORY"), "imagedir"),
    MaxSides: []int{300, 600, 1200},
}

router.Handler(http.MethodGet, "/images/*filepath", http.StripPrefix("/images", store))

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Image

type Image struct {
	Store Store
	Dir   string // relative to Store.Dir, becomes part of URL
	Name  string
	Size  int64
}

func (Image) Path

func (img Image) Path(maxSide int) string

type Store

type Store struct {
	CacheDir    string
	Dir         string
	JPEGQuality int // default: 80
	MaxSides    []int
}

func (Store) Get

func (store Store) Get(dir string) []Image

func (Store) Remove

func (store Store) Remove(dir, filename string) error

func (Store) ServeHTTP

func (store Store) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (Store) Upload

func (store Store) Upload(dir string, file multipart.File, header *multipart.FileHeader) error

Jump to

Keyboard shortcuts

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