thumb

package
v0.0.0-...-453d458 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BytesToThumb

func BytesToThumb(img []byte, thumbPath string) error

BytesToThumb creates a thumbnail from img, uses default size and default quality, and write the thumbnail to thumbPath.

func CheckFFmpeg

func CheckFFmpeg() (ok bool)

CheckFFmpeg 检查系统有没有安装 ffmpeg 和 ffprobe

func FrameNail

func FrameNail(in, out string, n int) error

FrameNail 截取视频文件 in 中的一帧 (第 n 秒), 并剪裁成正方形缩略图保存到文件 out 中。

func Nail

func Nail(img []byte, size, quality int) (*bytes.Buffer, error)

Nail creates a thumbnail of the img. Use default size(128) if size is set to zero. Use default quality(85) if quality is set to zero.

func NailBytesToBase64

func NailBytesToBase64(img []byte, thumbPath string) error

NailWrite64 convert the image to base64 and add prefix "data:image/jpeg;base64,"

func NailWrite

func NailWrite(imgPath, thumbPath string) error

NailWrite reads an image from imgPath, creates a thumbnail of it, and write the thumbnail to thumbPath.

func NailWrite64

func NailWrite64(imgPath, thumbPath string) error

NailWrite64 convert the image to base64 and add prefix "data:image/jpeg;base64,"

func OneFrame

func OneFrame(in, out string, n int) error

OneFrame 截取视频文件 in 的其中一帧 (第 n 秒),保存到文件 out 中。 建议 out 文件名的后缀为 ".jpg"。 例: OneFrame(video.mp4, screenshot.jpg, 10)

func OpenImage

func OpenImage(imgPath string) (image.Image, error)

func ReadImage

func ReadImage(img []byte) (image.Image, error)

ReadImage converts bytes to image. Supports webp.

func ResizeLimit

func ResizeLimit(img []byte, limit float64, quality int) (*bytes.Buffer, error)

ResizeLimit resizes the image if it's long side bigger than limit. Use default limit 900 if limit is set to zero. Use default quality 85 if quality is set to zero.

func ResizeToFile

func ResizeToFile(dst string, src []byte, limit float64, quality int) error

ResizeToFile resizes the image if it's long side bigger than limit. Use default limit 900 if limit is set to zero. Use default quality 85 if quality is set to zero.

func SmartCrop64

func SmartCrop64(imgPath, dstPath string) error

SmartCrop64 convert the image to base64 and add prefix "data:image/jpeg;base64,"

func SmartCropBytes64

func SmartCropBytes64(imgBytes []byte, dstPath string) error

Types

type SubImager

type SubImager interface {
	SubImage(r image.Rectangle) image.Image
}

Jump to

Keyboard shortcuts

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