pub struct QueryBuilder<'et> { /* private fields */ }Expand description
查询构建器
Implementations§
Source§impl<'et> QueryBuilder<'et>
impl<'et> QueryBuilder<'et>
Sourcepub fn include_unknown(self, yes: bool) -> Self
pub fn include_unknown(self, yes: bool) -> Self
包含未知标签
Sourcepub fn include_duplicates(self, yes: bool) -> Self
pub fn include_duplicates(self, yes: bool) -> Self
包含重复标签
Sourcepub fn raw_values(self, yes: bool) -> Self
pub fn raw_values(self, yes: bool) -> Self
显示原始数值(而非格式化后的值)
Sourcepub fn group_by_category(self, yes: bool) -> Self
pub fn group_by_category(self, yes: bool) -> Self
按类别分组(-g1 选项)
Sourcepub fn no_composite(self, yes: bool) -> Self
pub fn no_composite(self, yes: bool) -> Self
禁用复合标签生成
使用 -e 选项禁用复合标签(Composite tags)的生成。
复合标签是由 ExifTool 根据其他标签计算得出的派生标签。
§示例
use exiftool_rs_wrapper::ExifTool;
let exiftool = ExifTool::new()?;
// 只读取原始标签,不生成复合标签
let metadata = exiftool.query("photo.jpg")
.no_composite(true)
.execute()?;Sourcepub fn extract_embedded(self, level: Option<u8>) -> Self
pub fn extract_embedded(self, level: Option<u8>) -> Self
提取嵌入文件信息
使用 -ee 选项从文件中提取嵌入的文件信息。
例如从 RAW 文件中提取 JPEG 预览图的元数据。
§级别
None- 不提取嵌入文件(默认)Some(1)--ee提取直接嵌入的文件Some(2)--ee2提取所有层级的嵌入文件Some(3+)--ee3及以上更深入的提取
§示例
use exiftool_rs_wrapper::ExifTool;
let exiftool = ExifTool::new()?;
// 提取嵌入文件信息
let metadata = exiftool.query("photo.raw")
.extract_embedded(Some(1))
.execute()?;Sourcepub fn extension(self, ext: impl Into<String>) -> Self
pub fn extension(self, ext: impl Into<String>) -> Self
设置文件扩展名过滤
使用 -ext 选项只处理指定扩展名的文件。
可以使用多次来指定多个扩展名。
§示例
use exiftool_rs_wrapper::ExifTool;
let exiftool = ExifTool::new()?;
// 只处理 jpg 文件
let metadata = exiftool.query("/photos")
.extension("jpg")
.recursive(true)
.execute()?;
// 处理多个扩展名
let metadata = exiftool.query("/photos")
.extension("jpg")
.extension("png")
.extension("raw")
.recursive(true)
.execute()?;Sourcepub fn ignore(self, dir: impl Into<String>) -> Self
pub fn ignore(self, dir: impl Into<String>) -> Self
设置要忽略的目录
使用 -i 选项忽略指定的目录名称。
在递归处理时,匹配的目录将被跳过。
§示例
use exiftool_rs_wrapper::ExifTool;
let exiftool = ExifTool::new()?;
// 忽略 .git 和 node_modules 目录
let metadata = exiftool.query("/project")
.ignore(".git")
.ignore("node_modules")
.recursive(true)
.execute()?;Sourcepub fn recursive(self, yes: bool) -> Self
pub fn recursive(self, yes: bool) -> Self
递归处理子目录
使用 -r 选项递归处理目录中的所有文件。
§示例
use exiftool_rs_wrapper::ExifTool;
let exiftool = ExifTool::new()?;
// 递归处理整个目录树
let metadata = exiftool.query("/photos")
.recursive(true)
.extension("jpg")
.execute()?;Sourcepub fn progress(
self,
interval: Option<u32>,
title: Option<impl Into<String>>,
) -> Self
pub fn progress( self, interval: Option<u32>, title: Option<impl Into<String>>, ) -> Self
启用进度显示
使用 -progress 选项在处理文件时显示进度信息。
可以指定间隔(每隔多少文件显示一次)和标题。
§参数
interval- 每隔多少文件显示一次进度(None 表示每个文件都显示)title- 进度信息的标题(可选)
§示例
use exiftool_rs_wrapper::ExifTool;
let exiftool = ExifTool::new()?;
// 每 10 个文件显示一次进度
let metadata = exiftool.query("/photos")
.recursive(true)
.progress(Some(10), Some("Processing"))
.execute()?;添加多个标签查询
Sourcepub fn exclude_id(self, tag: TagId) -> Self
pub fn exclude_id(self, tag: TagId) -> Self
排除特定标签(使用 TagId)
Sourcepub fn coord_format(self, format: impl Into<String>) -> Self
pub fn coord_format(self, format: impl Into<String>) -> Self
设置 GPS 坐标格式
使用 -c 选项设置 GPS 坐标的输出格式
§示例
use exiftool_rs_wrapper::ExifTool;
let exiftool = ExifTool::new()?;
// 使用小数度格式
let metadata = exiftool.query("photo.jpg")
.coord_format("%.6f")
.execute()?;
// 使用度分秒格式
let metadata = exiftool.query("photo.jpg")
.coord_format("%d deg %d' %.2f\"")
.execute()?;Sourcepub fn date_format(self, format: impl Into<String>) -> Self
pub fn date_format(self, format: impl Into<String>) -> Self
设置日期/时间格式
使用 -d 选项设置日期/时间值的输出格式
§预设格式
"%Y:%m:%d %H:%M:%S"- 标准 EXIF 格式(默认)"%Y-%m-%d"- ISO 日期格式"%c"- 本地时间格式"%F %T"- ISO 8601 格式
§示例
use exiftool_rs_wrapper::ExifTool;
let exiftool = ExifTool::new()?;
// 使用 ISO 格式
let metadata = exiftool.query("photo.jpg")
.date_format("%Y-%m-%d %H:%M:%S")
.execute()?;Sourcepub fn print_format(self, format: impl Into<String>) -> Self
pub fn print_format(self, format: impl Into<String>) -> Self
设置自定义打印格式
使用 -p 选项按指定格式打印输出。
使用 $TAGNAME 语法引用标签值。
§格式语法
$TAGNAME- 插入标签值$TAGNAME#- 插入原始数值(无格式化)${TAGNAME:FMT}- 使用指定格式$$- 插入$字符
§示例
use exiftool_rs_wrapper::ExifTool;
let exiftool = ExifTool::new()?;
// 自定义输出格式
let output = exiftool.query("photo.jpg")
.print_format("$FileName: $DateTimeOriginal ($Make $Model)")
.execute_text()?;
println!("{}", output);Sourcepub fn separator(self, sep: impl Into<String>) -> Self
pub fn separator(self, sep: impl Into<String>) -> Self
设置列表项分隔符
使用 -sep 选项设置列表项的分隔符字符串
§示例
use exiftool_rs_wrapper::ExifTool;
let exiftool = ExifTool::new()?;
// 使用逗号分隔列表项
let metadata = exiftool.query("photo.jpg")
.separator(", ")
.execute()?;Sourcepub fn scan_for_xmp(self, yes: bool) -> Self
pub fn scan_for_xmp(self, yes: bool) -> Self
强制扫描 XMP 数据
使用 -scanForXMP 选项暴力扫描文件中的 XMP 数据
Sourcepub fn api_option(
self,
opt: impl Into<String>,
value: Option<impl Into<String>>,
) -> Self
pub fn api_option( self, opt: impl Into<String>, value: Option<impl Into<String>>, ) -> Self
设置 API 选项
使用 -api 选项设置 ExifTool API 选项。
常见选项包括:QuickTimeUTC, SystemTags, largefilesupport
§示例
use exiftool_rs_wrapper::ExifTool;
let exiftool = ExifTool::new()?;
// 启用 QuickTimeUTC
let metadata = exiftool.query("video.mp4")
.api_option("QuickTimeUTC", None::<&str>)
.execute()?;Sourcepub fn user_param(
self,
param: impl Into<String>,
value: Option<impl Into<String>>,
) -> Self
pub fn user_param( self, param: impl Into<String>, value: Option<impl Into<String>>, ) -> Self
设置用户参数
使用 -userParam 选项设置用户参数,可在配置文件中使用
§示例
use exiftool_rs_wrapper::ExifTool;
let exiftool = ExifTool::new()?;
// 设置自定义参数
let metadata = exiftool.query("photo.jpg")
.user_param("MyParam", Some("value"))
.execute()?;Sourcepub fn escape(self, format: EscapeFormat) -> Self
pub fn escape(self, format: EscapeFormat) -> Self
转义格式
使用 -E、-ex 或 -ec 选项转义标签值
Sourcepub fn force_print(self, yes: bool) -> Self
pub fn force_print(self, yes: bool) -> Self
强制打印
使用 -f 选项强制打印所有指定标签
Sourcepub fn group_names(self, level: Option<u8>) -> Self
pub fn group_names(self, level: Option<u8>) -> Self
打印组名
使用 -G 选项打印每个标签的组名
Sourcepub fn html_format(self, yes: bool) -> Self
pub fn html_format(self, yes: bool) -> Self
HTML 格式
使用 -h 选项以 HTML 格式输出
Sourcepub fn long_format(self, yes: bool) -> Self
pub fn long_format(self, yes: bool) -> Self
长格式输出
使用 -l 选项以长格式(2行)输出
Sourcepub fn short_format(self, level: Option<u8>) -> Self
pub fn short_format(self, level: Option<u8>) -> Self
短格式输出
使用 -s 或 -S 选项以短格式输出
Sourcepub fn tab_format(self, yes: bool) -> Self
pub fn tab_format(self, yes: bool) -> Self
Tab 分隔格式
使用 -t 选项以 Tab 分隔格式输出
Sourcepub fn table_format(self, yes: bool) -> Self
pub fn table_format(self, yes: bool) -> Self
表格格式
使用 -T 选项以表格格式输出
Sourcepub fn tag_out_ext(self, ext: impl Into<String>) -> Self
pub fn tag_out_ext(self, ext: impl Into<String>) -> Self
标签输出扩展名过滤
使用 -Wext 选项指定 -W 输出的文件类型
Sourcepub fn file_order(self, tag: impl Into<String>, descending: bool) -> Self
pub fn file_order(self, tag: impl Into<String>, descending: bool) -> Self
文件处理顺序
使用 -fileOrder 选项设置文件处理顺序
Sourcepub fn html_dump(self, offset: Option<u32>) -> Self
pub fn html_dump(self, offset: Option<u32>) -> Self
HTML二进制转储
使用 -htmlDump 选项生成HTML格式的二进制转储
可以指定可选的偏移量
Sourcepub fn php_format(self, yes: bool) -> Self
pub fn php_format(self, yes: bool) -> Self
PHP数组格式输出
使用 -php 选项导出为PHP数组格式
Sourcepub fn plot_format(self, yes: bool) -> Self
pub fn plot_format(self, yes: bool) -> Self
SVG plot格式输出
使用 -plot 选项输出为SVG plot文件
Sourcepub fn args_format(self, yes: bool) -> Self
pub fn args_format(self, yes: bool) -> Self
格式化为exiftool参数
使用 -args 选项将元数据格式化为exiftool参数格式
Sourcepub fn common_args(self, args: &[impl AsRef<str>]) -> Self
pub fn common_args(self, args: &[impl AsRef<str>]) -> Self
设置公共参数
使用 -common_args 选项定义在多个命令之间共享的参数
Sourcepub fn echo(
self,
text: impl Into<String>,
target: Option<impl Into<String>>,
) -> Self
pub fn echo( self, text: impl Into<String>, target: Option<impl Into<String>>, ) -> Self
输出文本到stdout或stderr
使用 -echo 选项在处理期间输出文本
text: 要输出的文本target: 输出目标,None表示stdout,Some(“stderr”)表示stderr
Sourcepub fn efile(self, filename: impl Into<String>) -> Self
pub fn efile(self, filename: impl Into<String>) -> Self
保存错误文件名到文件
使用 -efile 选项将处理失败的文件名保存到指定文件
Sourcepub fn execute_json(self) -> Result<Value>
pub fn execute_json(self) -> Result<Value>
执行查询并返回 JSON
Sourcepub fn execute_as<T: DeserializeOwned>(self) -> Result<T>
pub fn execute_as<T: DeserializeOwned>(self) -> Result<T>
执行查询并反序列化为自定义类型
Sourcepub fn execute_text(self) -> Result<String>
pub fn execute_text(self) -> Result<String>
执行查询并返回纯文本
当使用 -p (print_format) 选项时,
使用此方法获取纯文本输出而非 JSON
§示例
use exiftool_rs_wrapper::ExifTool;
let exiftool = ExifTool::new()?;
let output = exiftool.query("photo.jpg")
.print_format("$FileName: $DateTimeOriginal")
.execute_text()?;
println!("{}", output);