file

package
v1.30.36 Latest Latest
Warning

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

Go to latest
Published: May 16, 2022 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	JPEG = "jpeg" // jpeg/jpg
	PNG  = "png"  // png
)

Variables

This section is empty.

Functions

func ContainsTransparent added in v1.20.1

func ContainsTransparent(img image.Image) bool

ContainsTransparent judge png contains transparent

func GetFileContentType added in v1.20.1

func GetFileContentType(buffer []byte) string

GetFileContentType must a file file byte data[:512] image type: "image/jpeg","image/png"

func GetImageType added in v1.20.1

func GetImageType(buffer []byte) string

GetImageType jpeg,png

func PngToJpeg added in v1.20.1

func PngToJpeg(img image.Image, jpegF io.Writer, quality int) error

PngToJpeg png to jpeg quality: -1 noting

Types

type File

type File struct {
	File *multipart.FileHeader
	// file name
	Name string
	// path
	Path    string
	NewPath string
	// img attributes
	Width  int
	Height int

	// format 2006-01-02 15:04:05
	Format string
	// is img compress
	// default false, no compress
	IsComp  bool
	Quality int // default 80, 1-100

	// content type
	ContentType string
}

File upload

func NewFile added in v1.30.3

func NewFile(file *multipart.FileHeader, Name string) *File

NewFile file sugar

func (*File) Compress added in v1.30.3

func (f *File) Compress()

Compress Image

func (*File) ImageConfig added in v1.30.3

func (f *File) ImageConfig() (*image.Config, error)

ImageConfig return Upload Image Config width/height

func (*File) IsImg added in v1.30.3

func (f *File) IsImg() bool

func (*File) Save added in v1.30.3

func (f *File) Save() (err error)

Save file

func (*File) Upload added in v1.30.3

func (f *File) Upload() (err error)

Upload file

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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