xcmd

package
v0.2.12 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2023 License: BSD-3-Clause-Clear Imports: 9 Imported by: 0

Documentation

Overview

运行CMD命令 此处的命令需要在Linux下执行,请注意

Index

Constants

View Source
const (
	CONVERT  = iota // 常量0,用于确定命令位置
	FFMPEG          // 1
	GREP            // 2
	CUT             // 3
	SED             // 4
	QRENCODE        // 5
	IDENTIFY        // 6
	HEAD            // 7
	AWK             // 8
	BASH            // 9
	FILE            // 10
	FIND            // 11
	ZBARIMG         // 12
)

Variables

This section is empty.

Functions

func Audio2times

func Audio2times(filepath string) (uint, error)

根据音频获取音频时长,返回单位:毫秒 内部会调用Video2times命令中的ffmpeg来获取音频时长

filepath	视频地址[绝对路径]

func Exec

func Exec(name string, arg ...string) (string, error)

Exec 执行Shell命令并等待结果输出【避免僵尸进程】

如果要使用管道进行输出,则需要使用bash进行嵌套,如:

xgotool.Exec("bash", "-c", "ps aux | grep go")

name	命令参数
arg...	参数列表

func File2type

func File2type(path string) (uint8, error)

获取文件类型

path	文件路径

uint8返回类型确定:
0-未知 1-目录 2-Linux可执行程序 3-Linux下超链接 4-Linux Socket文件 5-Windows 可执行程序
10-JPEG图片文件 11-PNG图片文件 12-WEBP格式图片 13-GIF格式图片 14-BMP位图 15-TIFF格式图片 19-未知格式图片文件
20-ASCII编码的文本文件 21-UTF-8编码的文本文件 29-未知格式文本文件
31-7Z压缩文件 32-ZIP压缩文件 39-未知压缩文件
41-PDF文档 42-Word文档 43-Excel文档 44-PPT文档

func Find

func Find(path string, arg ...string) ([]string, error)

获取指定目录内的文件列表

func GuiOpen added in v0.2.9

func GuiOpen(url string) error

GUI环境下打开连接 此处使用Linux环境下的方式来调用,其他环境使用拆分编译的形式来实现

func Image2averageColor

func Image2averageColor(input string) (string, error)

获取图片的平均颜色【值为16进制的颜色色值(6位长度无前缀#,如:C6BEB2)】

input	输入的图片文件

func Image2mimeType

func Image2mimeType(input string) (string, error)

获取图片的Mime Type值,如:image/webp

input	输入的图片文件

func Image2webp

func Image2webp(input, output string) error

图片格式转换,智能根据后缀推测图片格式

input	输入图片的路径
output	输出图片的路径

func Image2wh

func Image2wh(filepath string) (uint, uint, error)

根据图片文件获取图片宽高,返回单位:px

filepath	图片地址

func Qrcode

func Qrcode(input, output string, conf *QrcodeConfig) error

转换为二维码

input	待转换的字符串
output	二维码文件存储位置(生成的文件为png格式图片,所以建议直接传入图片后缀png)
conf	二维码配置项

func QrcodeIdentification added in v0.1.30

func QrcodeIdentification(f string) (map[string][]string, error)

二维码识别

f	要识别的文件地址[支持输入图片文件地址]

func Quality

func Quality(input, output string, quality int) error

图像压缩,将图片压缩为指定质量的压缩图,宽高度不定

input	输入图片的路径
output	输出图片的路径
quality	压缩等级,0~100

func Thumb

func Thumb(input, output string, size uint) error

生成缩略图,画质较低

input	输入图片的路径
output	输出图片的路径
size	缩略图大小

func ThumbResize

func ThumbResize(input, output string, size uint) error

生成缩略图

和Thumb的区别为此处使用的-resize参数进行生成,效率稍慢,画质较高

func Video2convert

func Video2convert(input, output string) error

视频获取封面图【获取时长为00:00:00秒的图片】

func Video2image

func Video2image(input, output string, times uint) error

视频获取指定时长位置的图片

input	输入视频位置
output	输出图片位置
times	视频时长,单位:毫秒

func Video2times

func Video2times(filepath string) (uint, error)

根据视频获取视频时长,返回单位:毫秒

filepath	视频地址[绝对路径]

func Video2wh

func Video2wh(filepath string) (uint, uint, error)

根据视频获取视频宽高,返回单位:px

filepath	视频地址

Types

type QrcodeConfig

type QrcodeConfig struct {
	Size       uint   // 二维码大小(多少个像素点)【specify module size in dots (pixels). (default=3)】
	Level      string // 二维码质量【specify error correction level from L (lowest) to H (highest){LMQH}. (default=L)】
	Border     uint   // 外边距大小(多少个像素点)【specify the width of the margins. (default=2))】
	Background string // 背景色格式为RRGGBB[AA],默认:FFFFFF
	Foreground string // 前景色格式为RRGGBB[AA],默认:000000
	Replace    bool   // 若存在输出文件则直接覆盖?【默认false,返回错误信息】
}

二维码生成的配置信息

Jump to

Keyboard shortcuts

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