imagekit 是一个强大、快速且灵活的命令行工具,用于批量处理图片。它使用 rust 编写,通过并行处理来最大化性能,让你能轻松地对整个目录的图片进行尺寸调整、质量控制和添加高度可定制的水印。
.jpg, .jpeg, .png, .gif, .bmp, .webp)。-q 或 --quality 参数(1-100)微调输出质量,在文件大小和视觉保真度之间取得平衡。设置为 100 可获得最佳质量。RRGGBB 或 RRGGBBAA)精确控制水印颜色和透明度。
./target/release/imagekit \ -i example/img-src \ -o example/img-out \ --watermark-text "你好, World! - 印记"
如果你希望调整尺寸但不损失图片质量,请使用 --quality 100。
./target/release/imagekit -i example/img-src -o example/img-out --width 1024 --quality 100
./target/release/imagekit \ -i example/img-src \ -o example/img-out \ --watermark-text "@机密文件" \ --watermark-color 000000FF
| 选项 | 标志 | 描述 | 必需/可选 | 默认值 | 
|---|---|---|---|---|
| 输入目录 | 
-i, --input-dir
 |  
   包含需要处理的图片的源目录。 | 必需 | - | 
| 输出目录 | 
-o, --output-dir
 |  
   用于存放处理后图片的目录。 | 必需 | - | 
| 宽度 | --width |  
   (可选)调整图片的宽度。若不提供高度,则按比例缩放。 | 可选 | 原始宽度 | 
| 高度 | --height |  
   (可选)调整图片的高度。若不提供宽度,则按比例缩放。 | 可选 | 原始高度 | 
| 水印文字 | --watermark-text |  
   (可选)要添加的水印文字内容。 | 可选 | - | 
| 水印位置 | --watermark-position |  
   (可选)水印在图片上的位置。 | 可选 | se |  
  
| 字体大小 | --font-size |  
   (可选)水印文字的大小(单位:像素)。 | 可选 | 24 |  
  
| 水印颜色 | --watermark-color |  
   (可选)水印颜色,格式为 RRGGBB 或 RRGGBBAA。 | 可选 | 
FFFFFF80 (半透明白) |  
  
| 质量 | 
-q, --quality
 |  
   (可选)设置输出质量(1-100)。对于JPEG,影响压缩率;对于PNG,影响压缩速度。 | 可选 | 85 |  
  
| 输出格式 | --output-format |  
   (可选)指定输出图片的格式。 | 可选 | 原始格式 | 
watermark-position 的可用值:nw: 左上, north: 中上, ne: 右上west: 中左, center: 居中, east: 中右sw: 左下, south: 中下, se: 右下详情见:https://github.com/hzbd/imagekit/blob/master/README-zh.md
源码地址:点击下载
以上就是ImageKit:Rust 编写的一个强大、快速且灵活的命令行工具,用于批量处理图片的详细内容,更多请关注php中文网其它相关文章!
                        
                        每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
                Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号