特性
- 同时支持Window/Mac/Linux三种系统
- 单文件一键部署,无需安装依赖
- 支持添加水印并压缩一条龙服务
- 支持不加水印只进行压缩
- 支持自定义水印文本
- 支持自定义压缩级别
- 支持自定义水印文本颜色
- 支持自定义水印位置
- 支持自定义水印文本大小
缺点
- 暂时只支持英文文本水印,后续可开放全中文水印,如需中英混合水印可以考虑赞助后续开发
- 需要一个启动密码才能运行
- 由于打包了python解释器以及opencv和PIL库,生成的文件体积较大
- 暂时只支持jpeg,jpg,png三种格式
开发环境
Mac :10.15.6
打包/运行环境
- Mac :10.15.6
- Windows: 1903
- Linux: 在Centos 7.4.1708打包, 另外在基于Ubuntu18.04的Linuxmint 19.2中也测试过运行ok
English Manual
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
$ ./image_helper -h usage: image_helper.py [-h] -i [IMAGES [IMAGES ...]] [-t TEXT] [-cl COMPRESSION_LEVEL] [-s FONTSIZE] [-r RGB_COLOR] [-c COORDINATE] -p PASSWORD A tool to add text watermark on the bottom right by default of the image and compress it. The generated image file locates in the current dir just called 'new/'. optional arguments: -h, --help show this help message and exit -i [IMAGES [IMAGES ...]], --images [IMAGES [IMAGES ...]] The image file you wanna add text watermark and compress, or compress only -t TEXT, --text TEXT The text of the watermark itself -cl COMPRESSION_LEVEL, --compression_level COMPRESSION_LEVEL The compression level of the image you want to set. For jp(e)g image, the range is 0 to 100, the bigger, the bigger image you get,and the default is 50; For png image, the range is 0 to 9, the bigger, the smaller image you get, and the default is 5 -s FONTSIZE, --fontsize FONTSIZE The text watermark's font size, and the default is 50 -r RGB_COLOR, --rgb_color RGB_COLOR The rgb color for the text watermark, pls separate with half angle comma ','and the default is 192,192,192. -c COORDINATE, --coordinate COORDINATE The position of the watermark,and the range is 0 to 4, 0 means center, 1 means top left, 2 means top right, 3 means bottom left, 4 means bottom right, by default it's bottom right 4. -p PASSWORD, --password PASSWORD The boot password Tip: if you only want to compress images, do not pass -t arg. For more detailed Chinese documentation and usage tricks, Please visit below link: https://www.sharpgan.com/image-helper-for-windows-mac-linux/ |
中文手册
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
$ ./image_helper -h 使用: image_helper.py [-h] -i [IMAGES [IMAGES ...]] [-t TEXT] [-cl COMPRESSION_LEVEL] [-s FONTSIZE] [-r RGB_COLOR] [-c COORDINATE] -p PASSWORD 一个默认在右下角添加文本水印,生成的图片文件并压缩的工具, 生成的图片文件位于当前目录的new文件夹里面。 可选参数: -h, --help 显示帮助信息并退出 -i [IMAGES [IMAGES ...]], --images [IMAGES [IMAGES ...]] 你想添加水印并压缩或只压缩的图片文件 -t TEXT, --text TEXT 水印文本 -cl COMPRESSION_LEVEL, --compression_level COMPRESSION_LEVEL 你想设置的图片压缩级别。对于jp(e)g图片,取值范围是0-100,值越大, 你得到的图片大小越大,默认是50;对于png图片,取值范围是0-9,值越大, 你得到的图片越小,默认值是5. -s FONTSIZE, --fontsize FONTSIZE 文本水印的大小,默认是50 -r RGB_COLOR, --rgb_color RGB_COLOR 文本水印的rgb颜色值,请用半角逗号','隔开,默认是192,192,192. -c COORDINATE, --coordinate COORDINATE 水印的位置,传参取值范围是0-4,0表示中心,1表示左上,2表示右上, 3表示左下,4表示右下,默认是右下 -p PASSWORD, --password PASSWORD 启动密码 小提示:如果你只需要压缩图片,请不要传递-t参数。 更多详细的中文文档和使用技巧,请访问以下链接: https://www.sharpgan.com/image-helper-for-windows-mac-linux/ |
使用技巧
对于处理多张相同后缀名的图片,在Mac和Linux下,可以使用通配符,如下:
1 2 |
$ ./image_helper -t "https://www.sharpgan.com" -p wTjMEzGaW6v4UQZBCYeMQLbz -i *.png -s 80 |
在windows下可以使用for循环,如下:
1 2 |
for %i in (*.png) do image_helper.exe -t "sharpgan.com" -p wTjMEzGaW6v4UQZBCYeMQLbz -i %i -r "255,64,64" -s 100 -c 4 |
已在cmd下经过测试,运行详情可见下面的截图。 对于处理多张后缀名不同的图片,在Mac,Windows和Linux三种系统下都可以使用如下技巧:
1 2 |
$ ./image_helper -t "https://www.sharpgan.com" -p wTjMEzGaW6v4UQZBCYeMQLbz -i 1.png 2.jpg -s 80 |
运行截图
- Windows
- Linux
- Mac
下载链接
启动密码
[$]
1 |
bXfp9vNefebB5JuEEvtbNBvY |
[/$]