Categorygithub.com/jianbo-zh/go-thumbnail
modulepackage
1.0.14
Repository: https://github.com/jianbo-zh/go-thumbnail.git
Documentation: pkg.go.dev

# README

go-image

go-image

  1. 通过图片文件或者视频文件,从该文件中生产jpg格式的图或者缩略图, 如果该文件为 非图片非视频,那么返回错误,提示不支持该文件类型.
  2. 前期支持 输入 常规的 图片,视频格式 ,对 HEIF(.heic)图片格式 暂时不考虑.

一般情况下 只要 opencv和FFMpeg 能够处理,这个地方就能处理。

支持的图片

暂时不支持的图片格式

  • HEIF(.heic) (后期版本)

支持的视频

不支持的视频

环境问题

这个地方推荐使用

CPU版本

docker pull gocv/opencv:4.5.4

gpu版本 cuda11, cuda10 需要根据 响应的 显卡环境来.


docker pull gocv/opencv:4.5.4-gpu-cuda-11
docker pull gocv/opencv:4.5.4-gpu-cuda-10

how to test in docker.

docker run -v /Users/apple/workspace_stariverpool/go-image:/Users/apple/workspace_stariverpool/go-image -it   gocv/opencv:4.5.4 bash

cd /Users/apple/workspace_stariverpool/go-image
go mod tidy

go test -v -run=TestImageAndSave  .

这个地方还得检查一下.

git tag -a v0.0.8
git commit 
git push
git push --tags

# Packages

No description provided by the author

# Functions

No description provided by the author
No description provided by the author
No description provided by the author
ImageAndSave 该方法结合了 Image 和 Save2Jpg ,调用者不需要关心内部使用细节 根据原始文件路径,在 输出目录下生成对应的 缩略图和封面图片.
图片缩放要求: 对于一般图片,比例没有非常失调的 情况下, 最短一边保持 200,另外一边保持常宽比例不变 对于特殊比例失调的图片,处理下 最短一遍也是 200, 最常一边 从中切图 (保持 长的部分为 9:16 的比例, 那么就是 356) 比例失调定义为 最大边/最短边 >= 4倍以上 1.
1.
Save2Jpg 保存进文件.

# Constants

为 9:16 = 800:356.
最长一边/最短一边的 比例, 超过此比例,定义为 失调 4 倍定义为.
最短一边是 200 原参数 200 ---> 800.

# Variables

ErrFileNotExist is returned when the file(/directory) path is not exist.
ErrFilePathInvalid is returned when the file path is invalid.
No description provided by the author
ErrGoCVInner , for example, gocv inner error is returned when the file is heif format.
ErrIsNotFile this never happen , everything is file.
ErrNotSupportDirectory is returned when the file is directory.
ErrNotSupportFile4Img is returned when can't get a pic from the file, 比如 从 mp3文件里进行截图.
未支持的文件类型检查 [文件类型检查的时候失败].
ErrNotSupportFileImg is returned when the file is checked but can't be treated.
ErrNotSupportFileVideo is returned when the file is checked but can't be treated.
ErrSave2Jpg , 保存文件出错了.

# Structs

No description provided by the author