feat:图片整理

This commit is contained in:
2025-02-03 21:11:47 +08:00
parent 0e83c9e6b1
commit faee99c873
3 changed files with 401 additions and 201 deletions
+348 -148
View File
@@ -28,23 +28,77 @@ var supportImageTypes = []string{
} }
// gif图片 // gif图片
var horizontalGifImageList []string var gifImageList []string
var verticalGifImageList []string
var squareGifImageList []string
// 标准横向图片 // 横向图片
var horizontalNormalImageList []string
var horizontal1KImageList []string
var horizontal2KImageList []string
var horizontal3KImageList []string
var horizontal4KImageList []string
var horizontal5KImageList []string
var horizontal6KImageList []string
var horizontal7KImageList []string
var horizontal8KImageList []string
var horizontal9KImageList []string
var horizontalHKImageList []string
var horizontalStandard720PImageList []string var horizontalStandard720PImageList []string
var horizontalStandard1080PImageList []string var horizontalStandard1080PImageList []string
var horizontalStandard4KImageList []string var horizontalStandard4KImageList []string
var horizontalStandard8KImageList []string var horizontalStandard8KImageList []string
// 纵向图片
var verticalNormalImageList []string
var vertical1KImageList []string
var vertical2KImageList []string
var vertical3KImageList []string
var vertical4KImageList []string
var vertical5KImageList []string
var vertical6KImageList []string
var vertical7KImageList []string
var vertical8KImageList []string
var vertical9KImageList []string
var verticalHKImageList []string
// 等比图片
var squareNormalImageList []string
var square1KImageList []string
var square2KImageList []string
var square3KImageList []string
var square4KImageList []string
var square5KImageList []string
var square6KImageList []string
var square7KImageList []string
var square8KImageList []string
var square9KImageList []string
var squareHKImageList []string
// psd图片 // psd图片
var psdImageList []string var psdImageList []string
// 规格对应图片所在的路径 // 判断是否属于支持的图片文件
var hSpecs2ImageList = make(map[string][]string) func isSupportImage(imageType string) bool {
var vSpecs2ImageList = make(map[string][]string) for _, supportImageType := range supportImageTypes {
var mSpecs2ImageList = make(map[string][]string) if strings.EqualFold(supportImageType, imageType) {
return true
}
}
return false
}
// 读取一般图片文件信息
func readImageInfo(filePath string) (err error, width int, height int) {
file, err := os.Open(filePath) // 图片文件路径
if err != nil {
return err, 0, 0
}
defer file.Close()
img, _, err := image.DecodeConfig(file)
if err != nil {
return err, 0, 0
}
return nil, img.Width, img.Height
}
func DoHandleImage(rootDir string) { func DoHandleImage(rootDir string) {
total := len(vars.GlobalImagePathList) // 总数 total := len(vars.GlobalImagePathList) // 总数
@@ -131,137 +185,60 @@ func doPickImageFile(uid string, rootDir string, imagePath2WidthHeightMap map[st
width := util.String2int(width2Height[0]) width := util.String2int(width2Height[0])
height := util.String2int(width2Height[1]) height := util.String2int(width2Height[1])
suffix := vars.GlobalFilePath2FileExtMap[currentImagePath] suffix := vars.GlobalFilePath2FileExtMap[currentImagePath]
if strings.EqualFold(suffix, ".gif") {
handleGifImage(currentImagePath)
continue
}
if width > height { if width > height {
handleHorizontalImage(currentImagePath, width, height, suffix) handleHorizontalImage(currentImagePath, width, height)
continue continue
} }
if width < height { if width < height {
handleVerticalImage(currentImagePath, width, height, suffix) handleVerticalImage(currentImagePath, height)
continue continue
} }
handleSquareImage(currentImagePath, width, height, suffix) handleSquareImage(currentImagePath, width)
} }
moveStandardHorizontalImage(rootDir, uid) moveHorizontalImage(rootDir, uid)
moveStandardVerticalImage(rootDir, uid) moveVerticalImage(rootDir, uid)
moveStandardSquareImage(rootDir, uid) moveSquareImage(rootDir, uid)
// 移动特殊规格的
moveSpecsHorizontalImage(rootDir, uid)
moveSpecsVerticalImage(rootDir, uid)
moveSpecsSquareImage(rootDir, uid)
} }
func moveStandardSquareImage(rootDir string, uid string) { // 统一处理gif
pathSeparator := string(os.PathSeparator) func handleGifImage(path string) {
squareGifImagePath := rootDir + pathSeparator + uid + "-图片_等比_GIF" gifImageList = append(gifImageList, path)
if len(squareGifImageList) > 0 {
util.CreateDir(squareGifImagePath)
doMoveFileToDir(squareGifImageList, squareGifImagePath)
}
}
func moveSpecsSquareImage(rootDir string, uid string) {
pathSeparator := string(os.PathSeparator)
for dirName := range mSpecs2ImageList {
imagePath := rootDir + pathSeparator + uid + "-" + dirName
if len(mSpecs2ImageList[dirName]) > 0 {
util.CreateDir(imagePath)
doMoveFileToDir(mSpecs2ImageList[dirName], imagePath)
}
}
}
func handleSquareImage(currentImagePath string, width int, height int, suffix string) {
if strings.EqualFold(suffix, ".gif") {
squareGifImageList = append(squareGifImageList, currentImagePath)
return
}
// 非标准规格图片处理
prefix := fmt.Sprintf("M_%d_%d", width, height)
if mSpecs2ImageList[prefix] == nil {
mSpecs2ImageList[prefix] = make([]string, 1)
}
mSpecs2ImageList[prefix] = append(mSpecs2ImageList[prefix], currentImagePath)
}
// 移动垂直图片
func moveStandardVerticalImage(rootDir string, uid string) {
pathSeparator := string(os.PathSeparator)
verticalGifImagePath := rootDir + pathSeparator + uid + "-图片_竖屏_GIF"
if len(verticalGifImageList) > 0 {
util.CreateDir(verticalGifImagePath)
doMoveFileToDir(verticalGifImageList, verticalGifImagePath)
}
}
func moveSpecsVerticalImage(rootDir string, uid string) {
pathSeparator := string(os.PathSeparator)
for dirName := range vSpecs2ImageList {
imagePath := rootDir + pathSeparator + uid + "-" + dirName
if len(vSpecs2ImageList[dirName]) > 0 {
util.CreateDir(imagePath)
doMoveFileToDir(vSpecs2ImageList[dirName], imagePath)
}
}
}
// 移动水平图片
func moveStandardHorizontalImage(rootDir string, uid string) {
pathSeparator := string(os.PathSeparator)
horizontalGifImagePath := rootDir + pathSeparator + uid + "-图片_横屏_GIF"
horizontalStandard720PImagePath := rootDir + pathSeparator + uid + "-图片_横屏_720P"
horizontalStandard1080PImagePath := rootDir + pathSeparator + uid + "-图片_横屏_1080P"
horizontalStandard4KImagePath := rootDir + pathSeparator + uid + "-图片_横屏_4KP"
horizontalStandard8KImagePath := rootDir + pathSeparator + uid + "-图片_横屏_8KP"
if len(horizontalGifImageList) > 0 {
util.CreateDir(horizontalGifImagePath)
doMoveFileToDir(horizontalGifImageList, horizontalGifImagePath)
}
if len(horizontalStandard720PImageList) > 0 {
util.CreateDir(horizontalStandard720PImagePath)
doMoveFileToDir(horizontalStandard720PImageList, horizontalStandard720PImagePath)
}
if len(horizontalStandard1080PImageList) > 0 {
util.CreateDir(horizontalStandard1080PImagePath)
doMoveFileToDir(horizontalStandard1080PImageList, horizontalStandard1080PImagePath)
}
if len(horizontalStandard4KImageList) > 0 {
util.CreateDir(horizontalStandard4KImagePath)
doMoveFileToDir(horizontalStandard4KImageList, horizontalStandard4KImagePath)
}
if len(horizontalStandard8KImageList) > 0 {
util.CreateDir(horizontalStandard8KImagePath)
doMoveFileToDir(horizontalStandard8KImageList, horizontalStandard8KImagePath)
}
}
func moveSpecsHorizontalImage(rootDir string, uid string) {
pathSeparator := string(os.PathSeparator)
for dirName := range hSpecs2ImageList {
imagePath := rootDir + pathSeparator + uid + "-" + dirName
if len(hSpecs2ImageList[dirName]) > 0 {
util.CreateDir(imagePath)
doMoveFileToDir(hSpecs2ImageList[dirName], imagePath)
}
}
} }
// 处理垂直图片 // 处理垂直图片
func handleVerticalImage(currentImagePath string, width int, height int, suffix string) { func handleVerticalImage(currentImagePath string, height int) {
if strings.EqualFold(suffix, ".gif") { // 非标规格
verticalGifImageList = append(verticalGifImageList, currentImagePath) if height < 1000 {
return verticalNormalImageList = append(verticalNormalImageList, currentImagePath)
} else if height < 2000 {
vertical1KImageList = append(vertical1KImageList, currentImagePath)
} else if height < 3000 {
vertical2KImageList = append(vertical2KImageList, currentImagePath)
} else if height < 4000 {
vertical3KImageList = append(vertical3KImageList, currentImagePath)
} else if height < 5000 {
vertical4KImageList = append(vertical4KImageList, currentImagePath)
} else if height < 6000 {
vertical5KImageList = append(vertical5KImageList, currentImagePath)
} else if height < 7000 {
vertical6KImageList = append(vertical6KImageList, currentImagePath)
} else if height < 8000 {
vertical7KImageList = append(vertical7KImageList, currentImagePath)
} else if height < 9000 {
vertical8KImageList = append(vertical8KImageList, currentImagePath)
} else if height < 10000 {
vertical9KImageList = append(vertical9KImageList, currentImagePath)
} else if height > 10000 {
verticalHKImageList = append(verticalHKImageList, currentImagePath)
} }
// 非标准规格图片处理
prefix := fmt.Sprintf("V_%d_%d", width, height)
if vSpecs2ImageList[prefix] == nil {
vSpecs2ImageList[prefix] = make([]string, 1)
}
vSpecs2ImageList[prefix] = append(vSpecs2ImageList[prefix], currentImagePath)
} }
// 处理横向图片 // 处理横向图片
func handleHorizontalImage(currentImagePath string, width int, height int, suffix string) { func handleHorizontalImage(currentImagePath string, width int, height int) {
if strings.EqualFold(suffix, ".gif") {
horizontalGifImageList = append(horizontalGifImageList, currentImagePath)
return
}
if width >= 1000 && width < 2000 {
// 1280 x 720 -> 720p // 1280 x 720 -> 720p
if width == 1280 && height == 720 { if width == 1280 && height == 720 {
horizontalStandard720PImageList = append(horizontalStandard720PImageList, currentImagePath) horizontalStandard720PImageList = append(horizontalStandard720PImageList, currentImagePath)
@@ -272,47 +249,270 @@ func handleHorizontalImage(currentImagePath string, width int, height int, suffi
horizontalStandard1080PImageList = append(horizontalStandard1080PImageList, currentImagePath) horizontalStandard1080PImageList = append(horizontalStandard1080PImageList, currentImagePath)
return return
} }
} else if width >= 3000 && width < 4000 {
// 3840 x 2160 -> 4k // 3840 x 2160 -> 4k
if width == 3840 && height == 2160 { if width == 3840 && height == 2160 {
horizontalStandard4KImageList = append(horizontalStandard4KImageList, currentImagePath) horizontalStandard4KImageList = append(horizontalStandard4KImageList, currentImagePath)
return return
} }
} else if width >= 7000 && width < 8000 {
// 7680 x 4320 -> 8k // 7680 x 4320 -> 8k
if width == 7680 && height == 4320 { if width == 7680 && height == 4320 {
horizontalStandard8KImageList = append(horizontalStandard8KImageList, currentImagePath) horizontalStandard8KImageList = append(horizontalStandard8KImageList, currentImagePath)
return return
} }
// 非标规格
if width < 1000 {
horizontalNormalImageList = append(horizontalNormalImageList, currentImagePath)
} else if width < 2000 {
horizontal1KImageList = append(horizontal1KImageList, currentImagePath)
} else if width < 3000 {
horizontal2KImageList = append(horizontal2KImageList, currentImagePath)
} else if width < 4000 {
horizontal3KImageList = append(horizontal3KImageList, currentImagePath)
} else if width < 5000 {
horizontal4KImageList = append(horizontal4KImageList, currentImagePath)
} else if width < 6000 {
horizontal5KImageList = append(horizontal5KImageList, currentImagePath)
} else if width < 7000 {
horizontal6KImageList = append(horizontal6KImageList, currentImagePath)
} else if width < 8000 {
horizontal7KImageList = append(horizontal7KImageList, currentImagePath)
} else if width < 9000 {
horizontal8KImageList = append(horizontal8KImageList, currentImagePath)
} else if width < 10000 {
horizontal9KImageList = append(horizontal9KImageList, currentImagePath)
} else if width > 10000 {
horizontalHKImageList = append(horizontalHKImageList, currentImagePath)
} }
// 非标准规格图片处理
prefix := fmt.Sprintf("H_%d_%d", width, height)
if hSpecs2ImageList[prefix] == nil {
hSpecs2ImageList[prefix] = make([]string, 1)
}
hSpecs2ImageList[prefix] = append(hSpecs2ImageList[prefix], currentImagePath)
} }
// 判断是否属于支持的图片文件 // 处理等比图片
func isSupportImage(imageType string) bool { func handleSquareImage(currentImagePath string, width int) {
for _, supportImageType := range supportImageTypes { // 非标规格
if strings.EqualFold(supportImageType, imageType) { if width < 1000 {
return true squareNormalImageList = append(squareNormalImageList, currentImagePath)
} else if width < 2000 {
square1KImageList = append(square1KImageList, currentImagePath)
} else if width < 3000 {
square2KImageList = append(square2KImageList, currentImagePath)
} else if width < 4000 {
square3KImageList = append(square3KImageList, currentImagePath)
} else if width < 5000 {
square4KImageList = append(square4KImageList, currentImagePath)
} else if width < 6000 {
square5KImageList = append(square5KImageList, currentImagePath)
} else if width < 7000 {
square6KImageList = append(square6KImageList, currentImagePath)
} else if width < 8000 {
square7KImageList = append(square7KImageList, currentImagePath)
} else if width < 9000 {
square8KImageList = append(square8KImageList, currentImagePath)
} else if width < 10000 {
square9KImageList = append(square9KImageList, currentImagePath)
} else if width > 10000 {
squareHKImageList = append(squareHKImageList, currentImagePath)
} }
}
return false
} }
// 读取一般图片文件信息 // 移动水平图片
func readImageInfo(filePath string) (err error, width int, height int) { func moveHorizontalImage(rootDir string, uid string) {
file, err := os.Open(filePath) // 图片文件路径 pathSeparator := string(os.PathSeparator)
if err != nil { // 标准
return err, 0, 0 if len(horizontalStandard720PImageList) > 0 {
horizontalStandard720PImagePath := rootDir + pathSeparator + uid + "-图片_横屏_720P"
util.CreateDir(horizontalStandard720PImagePath)
doMoveFileToDir(horizontalStandard720PImageList, horizontalStandard720PImagePath)
} }
defer file.Close() if len(horizontalStandard1080PImageList) > 0 {
img, _, err := image.DecodeConfig(file) horizontalStandard1080PImagePath := rootDir + pathSeparator + uid + "-图片_横屏_1080P"
if err != nil { util.CreateDir(horizontalStandard1080PImagePath)
return err, 0, 0 doMoveFileToDir(horizontalStandard1080PImageList, horizontalStandard1080PImagePath)
}
if len(horizontalStandard4KImageList) > 0 {
horizontalStandard4KImagePath := rootDir + pathSeparator + uid + "-图片_横屏_4KP"
util.CreateDir(horizontalStandard4KImagePath)
doMoveFileToDir(horizontalStandard4KImageList, horizontalStandard4KImagePath)
}
if len(horizontalStandard8KImageList) > 0 {
horizontalStandard8KImagePath := rootDir + pathSeparator + uid + "-图片_横屏_8KP"
util.CreateDir(horizontalStandard8KImagePath)
doMoveFileToDir(horizontalStandard8KImageList, horizontalStandard8KImagePath)
}
// 非标准
if len(horizontalNormalImageList) > 0 {
horizontalNormalImagePath := rootDir + pathSeparator + uid + "-图片_横屏_普通"
util.CreateDir(horizontalNormalImagePath)
doMoveFileToDir(horizontalNormalImageList, horizontalNormalImagePath)
}
if len(horizontal1KImageList) > 0 {
horizontal1kImagePath := rootDir + pathSeparator + uid + "-图片_横屏_1K"
util.CreateDir(horizontal1kImagePath)
doMoveFileToDir(horizontal1KImageList, horizontal1kImagePath)
}
if len(horizontal2KImageList) > 0 {
horizontal2kImagePath := rootDir + pathSeparator + uid + "-图片_横屏_2K"
util.CreateDir(horizontal2kImagePath)
doMoveFileToDir(horizontal2KImageList, horizontal2kImagePath)
}
if len(horizontal3KImageList) > 0 {
horizontal3kImagePath := rootDir + pathSeparator + uid + "-图片_横屏_3K"
util.CreateDir(horizontal3kImagePath)
doMoveFileToDir(horizontal3KImageList, horizontal3kImagePath)
}
if len(horizontal4KImageList) > 0 {
horizontal4kImagePath := rootDir + pathSeparator + uid + "-图片_横屏_4K"
util.CreateDir(horizontal4kImagePath)
doMoveFileToDir(horizontal4KImageList, horizontal4kImagePath)
}
if len(horizontal5KImageList) > 0 {
horizontal5kImagePath := rootDir + pathSeparator + uid + "-图片_横屏_5K"
util.CreateDir(horizontal5kImagePath)
doMoveFileToDir(horizontal5KImageList, horizontal5kImagePath)
}
if len(horizontal6KImageList) > 0 {
horizontal6kImagePath := rootDir + pathSeparator + uid + "-图片_横屏_6K"
util.CreateDir(horizontal6kImagePath)
doMoveFileToDir(horizontal6KImageList, horizontal6kImagePath)
}
if len(horizontal7KImageList) > 0 {
horizontal7KImagePath := rootDir + pathSeparator + uid + "-图片_横屏_7K"
util.CreateDir(horizontal7KImagePath)
doMoveFileToDir(horizontal7KImageList, horizontal7KImagePath)
}
if len(horizontal8KImageList) > 0 {
horizontal8kImagePath := rootDir + pathSeparator + uid + "-图片_横屏_8K"
util.CreateDir(horizontal8kImagePath)
doMoveFileToDir(horizontal8KImageList, horizontal8kImagePath)
}
if len(horizontal9KImageList) > 0 {
horizontal9kImagePath := rootDir + pathSeparator + uid + "-图片_横屏_9K"
util.CreateDir(horizontal9kImagePath)
doMoveFileToDir(horizontal9KImageList, horizontal9kImagePath)
}
if len(horizontalHKImageList) > 0 {
horizontalHkImagePath := rootDir + pathSeparator + uid + "-图片_横屏_原图"
util.CreateDir(horizontalHkImagePath)
doMoveFileToDir(horizontalHKImageList, horizontalHkImagePath)
}
}
// 移动垂直图片
func moveVerticalImage(rootDir string, uid string) {
pathSeparator := string(os.PathSeparator)
// 非标准
if len(verticalNormalImageList) > 0 {
verticalNormalImagePath := rootDir + pathSeparator + uid + "-图片_竖屏_普通"
util.CreateDir(verticalNormalImagePath)
doMoveFileToDir(verticalNormalImageList, verticalNormalImagePath)
}
if len(vertical1KImageList) > 0 {
vertical1kImagePath := rootDir + pathSeparator + uid + "-图片_竖屏_1K"
util.CreateDir(vertical1kImagePath)
doMoveFileToDir(vertical1KImageList, vertical1kImagePath)
}
if len(vertical2KImageList) > 0 {
vertical2kImagePath := rootDir + pathSeparator + uid + "-图片_竖屏_2K"
util.CreateDir(vertical2kImagePath)
doMoveFileToDir(vertical2KImageList, vertical2kImagePath)
}
if len(vertical3KImageList) > 0 {
vertical3kImagePath := rootDir + pathSeparator + uid + "-图片_竖屏_3K"
util.CreateDir(vertical3kImagePath)
doMoveFileToDir(vertical3KImageList, vertical3kImagePath)
}
if len(vertical4KImageList) > 0 {
vertical4kImagePath := rootDir + pathSeparator + uid + "-图片_竖屏_4K"
util.CreateDir(vertical4kImagePath)
doMoveFileToDir(vertical4KImageList, vertical4kImagePath)
}
if len(vertical5KImageList) > 0 {
vertical5kImagePath := rootDir + pathSeparator + uid + "-图片_竖屏_5K"
util.CreateDir(vertical5kImagePath)
doMoveFileToDir(vertical5KImageList, vertical5kImagePath)
}
if len(vertical6KImageList) > 0 {
vertical6kImagePath := rootDir + pathSeparator + uid + "-图片_竖屏_6K"
util.CreateDir(vertical6kImagePath)
doMoveFileToDir(vertical6KImageList, vertical6kImagePath)
}
if len(vertical7KImageList) > 0 {
vertical7KImagePath := rootDir + pathSeparator + uid + "-图片_竖屏_7K"
util.CreateDir(vertical7KImagePath)
doMoveFileToDir(vertical7KImageList, vertical7KImagePath)
}
if len(vertical8KImageList) > 0 {
vertical8kImagePath := rootDir + pathSeparator + uid + "-图片_竖屏_8K"
util.CreateDir(vertical8kImagePath)
doMoveFileToDir(vertical8KImageList, vertical8kImagePath)
}
if len(vertical9KImageList) > 0 {
vertical9kImagePath := rootDir + pathSeparator + uid + "-图片_竖屏_9K"
util.CreateDir(vertical9kImagePath)
doMoveFileToDir(vertical9KImageList, vertical9kImagePath)
}
if len(verticalHKImageList) > 0 {
verticalHkImagePath := rootDir + pathSeparator + uid + "-图片_竖屏_原图"
util.CreateDir(verticalHkImagePath)
doMoveFileToDir(verticalHKImageList, verticalHkImagePath)
}
}
// 移动等比图片
func moveSquareImage(rootDir string, uid string) {
pathSeparator := string(os.PathSeparator)
// 非标准
if len(squareNormalImageList) > 0 {
squareNormalImagePath := rootDir + pathSeparator + uid + "-图片_等比_普通"
util.CreateDir(squareNormalImagePath)
doMoveFileToDir(squareNormalImageList, squareNormalImagePath)
}
if len(square1KImageList) > 0 {
square1kImagePath := rootDir + pathSeparator + uid + "-图片_等比_1K"
util.CreateDir(square1kImagePath)
doMoveFileToDir(square1KImageList, square1kImagePath)
}
if len(square2KImageList) > 0 {
square2kImagePath := rootDir + pathSeparator + uid + "-图片_等比_2K"
util.CreateDir(square2kImagePath)
doMoveFileToDir(square2KImageList, square2kImagePath)
}
if len(square3KImageList) > 0 {
square3kImagePath := rootDir + pathSeparator + uid + "-图片_等比_3K"
util.CreateDir(square3kImagePath)
doMoveFileToDir(square3KImageList, square3kImagePath)
}
if len(square4KImageList) > 0 {
square4kImagePath := rootDir + pathSeparator + uid + "-图片_等比_4K"
util.CreateDir(square4kImagePath)
doMoveFileToDir(square4KImageList, square4kImagePath)
}
if len(square5KImageList) > 0 {
square5kImagePath := rootDir + pathSeparator + uid + "-图片_等比_5K"
util.CreateDir(square5kImagePath)
doMoveFileToDir(square5KImageList, square5kImagePath)
}
if len(square6KImageList) > 0 {
square6kImagePath := rootDir + pathSeparator + uid + "-图片_等比_6K"
util.CreateDir(square6kImagePath)
doMoveFileToDir(square6KImageList, square6kImagePath)
}
if len(square7KImageList) > 0 {
square7KImagePath := rootDir + pathSeparator + uid + "-图片_等比_7K"
util.CreateDir(square7KImagePath)
doMoveFileToDir(square7KImageList, square7KImagePath)
}
if len(square8KImageList) > 0 {
square8kImagePath := rootDir + pathSeparator + uid + "-图片_等比_8K"
util.CreateDir(square8kImagePath)
doMoveFileToDir(square8KImageList, square8kImagePath)
}
if len(square9KImageList) > 0 {
square9kImagePath := rootDir + pathSeparator + uid + "-图片_等比_9K"
util.CreateDir(square9kImagePath)
doMoveFileToDir(square9KImageList, square9kImagePath)
}
if len(squareHKImageList) > 0 {
squareHkImagePath := rootDir + pathSeparator + uid + "-图片_等比_原图"
util.CreateDir(squareHkImagePath)
doMoveFileToDir(squareHKImageList, squareHkImagePath)
} }
return nil, img.Width, img.Height
} }
+38 -38
View File
@@ -584,25 +584,25 @@ func handleVerticalVideo(currentVideoPath string, height int, suffix string) {
} }
if height < 1000 { if height < 1000 {
verticalNormalVideoList = append(verticalNormalVideoList, currentVideoPath) verticalNormalVideoList = append(verticalNormalVideoList, currentVideoPath)
} else if height >= 1000 && height < 2000 { } else if height < 2000 {
vertical1KVideoList = append(vertical1KVideoList, currentVideoPath) vertical1KVideoList = append(vertical1KVideoList, currentVideoPath)
} else if height >= 2000 && height < 3000 { } else if height < 3000 {
vertical2KVideoList = append(vertical2KVideoList, currentVideoPath) vertical2KVideoList = append(vertical2KVideoList, currentVideoPath)
} else if height >= 3000 && height < 4000 { } else if height < 4000 {
vertical3KVideoList = append(vertical3KVideoList, currentVideoPath) vertical3KVideoList = append(vertical3KVideoList, currentVideoPath)
} else if height >= 4000 && height < 5000 { } else if height < 5000 {
vertical4KVideoList = append(vertical4KVideoList, currentVideoPath) vertical4KVideoList = append(vertical4KVideoList, currentVideoPath)
} else if height >= 5000 && height < 6000 { } else if height < 6000 {
vertical5KVideoList = append(vertical5KVideoList, currentVideoPath) vertical5KVideoList = append(vertical5KVideoList, currentVideoPath)
} else if height >= 6000 && height < 7000 { } else if height < 7000 {
vertical6KVideoList = append(vertical6KVideoList, currentVideoPath) vertical6KVideoList = append(vertical6KVideoList, currentVideoPath)
} else if height >= 7000 && height < 8000 { } else if height < 8000 {
vertical7KVideoList = append(vertical7KVideoList, currentVideoPath) vertical7KVideoList = append(vertical7KVideoList, currentVideoPath)
} else if height >= 8000 && height < 9000 { } else if height < 9000 {
vertical8KVideoList = append(vertical8KVideoList, currentVideoPath) vertical8KVideoList = append(vertical8KVideoList, currentVideoPath)
} else if height >= 9000 && height < 10000 { } else if height < 10000 {
vertical9KVideoList = append(vertical9KVideoList, currentVideoPath) vertical9KVideoList = append(vertical9KVideoList, currentVideoPath)
} else if height >= 10000 { } else if height > 10000 {
verticalHKVideoList = append(verticalHKVideoList, currentVideoPath) verticalHKVideoList = append(verticalHKVideoList, currentVideoPath)
} }
} }
@@ -620,7 +620,7 @@ func handleHorizontalVideo(currentVideoPath string, width int, height int, suffi
// 640 × 360 // 640 × 360
// 640 × 480 // 640 × 480
horizontalNormalVideoList = append(horizontalNormalVideoList, currentVideoPath) horizontalNormalVideoList = append(horizontalNormalVideoList, currentVideoPath)
} else if width >= 1000 && width < 2000 { } else if width < 2000 {
// 1280 x 720 -> 720p // 1280 x 720 -> 720p
if width == 1280 && height == 720 { if width == 1280 && height == 720 {
horizontalStandard720PVideoList = append(horizontalStandard720PVideoList, currentVideoPath) horizontalStandard720PVideoList = append(horizontalStandard720PVideoList, currentVideoPath)
@@ -632,33 +632,33 @@ func handleHorizontalVideo(currentVideoPath string, width int, height int, suffi
return return
} }
horizontal1KVideoList = append(horizontal1KVideoList, currentVideoPath) horizontal1KVideoList = append(horizontal1KVideoList, currentVideoPath)
} else if width >= 2000 && width < 3000 { } else if width < 3000 {
horizontal2KVideoList = append(horizontal2KVideoList, currentVideoPath) horizontal2KVideoList = append(horizontal2KVideoList, currentVideoPath)
} else if width >= 3000 && width < 4000 { } else if width < 4000 {
// 3840 x 2160 -> 4k // 3840 x 2160 -> 4k
if width == 3840 && height == 2160 { if width == 3840 && height == 2160 {
horizontalStandard4KVideoList = append(horizontalStandard4KVideoList, currentVideoPath) horizontalStandard4KVideoList = append(horizontalStandard4KVideoList, currentVideoPath)
return return
} }
horizontal3KVideoList = append(horizontal3KVideoList, currentVideoPath) horizontal3KVideoList = append(horizontal3KVideoList, currentVideoPath)
} else if width >= 4000 && width < 5000 { } else if width < 5000 {
horizontal4KVideoList = append(horizontal4KVideoList, currentVideoPath) horizontal4KVideoList = append(horizontal4KVideoList, currentVideoPath)
} else if width >= 5000 && width < 6000 { } else if width < 6000 {
horizontal5KVideoList = append(horizontal5KVideoList, currentVideoPath) horizontal5KVideoList = append(horizontal5KVideoList, currentVideoPath)
} else if width >= 6000 && width < 7000 { } else if width < 7000 {
horizontal6KVideoList = append(horizontal6KVideoList, currentVideoPath) horizontal6KVideoList = append(horizontal6KVideoList, currentVideoPath)
} else if width >= 7000 && width < 8000 { } else if width < 8000 {
// 7680 x 4320 -> 8k // 7680 x 4320 -> 8k
if width == 7680 && height == 4320 { if width == 7680 && height == 4320 {
horizontalStandard8KVideoList = append(horizontalStandard8KVideoList, currentVideoPath) horizontalStandard8KVideoList = append(horizontalStandard8KVideoList, currentVideoPath)
return return
} }
horizontal7KVideoList = append(horizontal7KVideoList, currentVideoPath) horizontal7KVideoList = append(horizontal7KVideoList, currentVideoPath)
} else if width >= 8000 && width < 9000 { } else if width < 9000 {
horizontal8KVideoList = append(horizontal8KVideoList, currentVideoPath) horizontal8KVideoList = append(horizontal8KVideoList, currentVideoPath)
} else if width >= 9000 && width < 10000 { } else if width < 10000 {
horizontal9KVideoList = append(horizontal9KVideoList, currentVideoPath) horizontal9KVideoList = append(horizontal9KVideoList, currentVideoPath)
} else if width >= 10000 { } else if width > 10000 {
horizontalHKVideoList = append(horizontalHKVideoList, currentVideoPath) horizontalHKVideoList = append(horizontalHKVideoList, currentVideoPath)
} }
} }
@@ -669,9 +669,6 @@ func handleSquareVideo(currentVideoPath string, width int, height int, suffix st
squareGifVideoList = append(squareGifVideoList, currentVideoPath) squareGifVideoList = append(squareGifVideoList, currentVideoPath)
return return
} }
if width < 1000 {
squareNormalVideoList = append(squareNormalVideoList, currentVideoPath)
} else if width >= 1000 && width < 2000 {
// 1280 x 720 -> 720p // 1280 x 720 -> 720p
if width == 1280 && height == 720 { if width == 1280 && height == 720 {
squareStandard720PVideoList = append(squareStandard720PVideoList, currentVideoPath) squareStandard720PVideoList = append(squareStandard720PVideoList, currentVideoPath)
@@ -682,34 +679,37 @@ func handleSquareVideo(currentVideoPath string, width int, height int, suffix st
squareStandard1080PVideoList = append(squareStandard1080PVideoList, currentVideoPath) squareStandard1080PVideoList = append(squareStandard1080PVideoList, currentVideoPath)
return return
} }
square1KVideoList = append(square1KVideoList, currentVideoPath)
} else if width >= 2000 && width < 3000 {
square2KVideoList = append(square2KVideoList, currentVideoPath)
} else if width >= 3000 && width < 4000 {
// 3840 x 2160 -> 4k // 3840 x 2160 -> 4k
if width == 3840 && height == 2160 { if width == 3840 && height == 2160 {
squareStandard4KVideoList = append(squareStandard4KVideoList, currentVideoPath) squareStandard4KVideoList = append(squareStandard4KVideoList, currentVideoPath)
return return
} }
square3KVideoList = append(square3KVideoList, currentVideoPath)
} else if width >= 4000 && width < 5000 {
square4KVideoList = append(square4KVideoList, currentVideoPath)
} else if width >= 5000 && width < 6000 {
square5KVideoList = append(square5KVideoList, currentVideoPath)
} else if width >= 6000 && width < 7000 {
square6KVideoList = append(square6KVideoList, currentVideoPath)
} else if width >= 7000 && width < 8000 {
// 7680 x 4320 -> 8k // 7680 x 4320 -> 8k
if width == 7680 && height == 4320 { if width == 7680 && height == 4320 {
squareStandard8KVideoList = append(squareStandard8KVideoList, currentVideoPath) squareStandard8KVideoList = append(squareStandard8KVideoList, currentVideoPath)
return return
} }
if width < 1000 {
squareNormalVideoList = append(squareNormalVideoList, currentVideoPath)
} else if width < 2000 {
square1KVideoList = append(square1KVideoList, currentVideoPath)
} else if width < 3000 {
square2KVideoList = append(square2KVideoList, currentVideoPath)
} else if width < 4000 {
square3KVideoList = append(square3KVideoList, currentVideoPath)
} else if width < 5000 {
square4KVideoList = append(square4KVideoList, currentVideoPath)
} else if width < 6000 {
square5KVideoList = append(square5KVideoList, currentVideoPath)
} else if width < 7000 {
square6KVideoList = append(square6KVideoList, currentVideoPath)
} else if width < 8000 {
square7KVideoList = append(square7KVideoList, currentVideoPath) square7KVideoList = append(square7KVideoList, currentVideoPath)
} else if width >= 8000 && width < 9000 { } else if width < 9000 {
square8KVideoList = append(square8KVideoList, currentVideoPath) square8KVideoList = append(square8KVideoList, currentVideoPath)
} else if width >= 9000 && width < 10000 { } else if width < 10000 {
square9KVideoList = append(square9KVideoList, currentVideoPath) square9KVideoList = append(square9KVideoList, currentVideoPath)
} else if width >= 10000 { } else if width > 10000 {
squareHKVideoList = append(squareHKVideoList, currentVideoPath) squareHKVideoList = append(squareHKVideoList, currentVideoPath)
} }
} }
+3 -3
View File
@@ -24,9 +24,9 @@ func main() {
if len(vars.GlobalImagePathList) > 0 { if len(vars.GlobalImagePathList) > 0 {
core.DoHandleImage(rootDir) core.DoHandleImage(rootDir)
} }
if len(vars.GlobalVideoPathList) > 0 { //if len(vars.GlobalVideoPathList) > 0 {
core.DoHandleVideo(rootDir) // core.DoHandleVideo(rootDir)
} //}
fmt.Println("=== 5s后自动退出") fmt.Println("=== 5s后自动退出")
time.Sleep(time.Second * 5) time.Sleep(time.Second * 5)
} }