file

package
v1.30.34 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2022 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

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

Variables

This section is empty.

Functions

func ContainsTransparent

func ContainsTransparent(img image.Image) bool

ContainsTransparent judge png contains transparent

func GetFileContentType added in v1.30.34

func GetFileContentType(buffer []byte) string

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

func GetImageType added in v1.30.34

func GetImageType(buffer []byte) string

GetImageType jpeg,png

func PngToJpeg

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

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

NewFile file sugar

func (*File) Compress

func (f *File) Compress()

Compress Image

func (*File) ImageConfig

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

ImageConfig return Upload Image Config width/height

func (*File) IsImg

func (f *File) IsImg() bool

func (*File) Save

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

Save file

func (*File) Upload

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