pub struct WriteBuilder<'et> { /* private fields */ }Expand description
写入构建器
Implementations§
Source§impl<'et> WriteBuilder<'et>
impl<'et> WriteBuilder<'et>
设置多个标签
Sourcepub fn overwrite_original(self, yes: bool) -> Self
pub fn overwrite_original(self, yes: bool) -> Self
覆盖原始文件(不创建备份)
Sourcepub fn write_mode(self, mode: WriteMode) -> Self
pub fn write_mode(self, mode: WriteMode) -> Self
设置写入模式
使用 -wm 选项设置写入/创建标签的模式
§模式
WriteMode::Write(w) - 写入标签(默认)WriteMode::Create(c) - 仅创建标签(不修改现有标签)WriteMode::WriteCreate(wc) - 写入或创建
§示例
use exiftool_rs_wrapper::{ExifTool, WriteMode};
let exiftool = ExifTool::new()?;
// 仅创建新标签,不修改现有标签
exiftool.write("photo.jpg")
.tag("NewTag", "value")
.write_mode(WriteMode::Create)
.execute()?;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 选项
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 选项设置用户参数
Sourcepub fn ignore_minor_errors(self, yes: bool) -> Self
pub fn ignore_minor_errors(self, yes: bool) -> Self
忽略次要错误
使用 -m 选项忽略次要错误和警告,继续处理其他文件。
这在批量处理时很有用,可以避免单个文件错误导致整个操作失败。
§示例
use exiftool_rs_wrapper::ExifTool;
let exiftool = ExifTool::new()?;
// 批量写入时忽略次要错误
exiftool.write("photo.jpg")
.tag("Copyright", "© 2026")
.ignore_minor_errors(true)
.execute()?;Sourcepub fn preserve_time(self, yes: bool) -> Self
pub fn preserve_time(self, yes: bool) -> Self
保留文件修改时间
使用 -P 选项保留文件的原始修改时间。
默认情况下,ExifTool 会更新文件的修改时间为当前时间。
§示例
use exiftool_rs_wrapper::ExifTool;
let exiftool = ExifTool::new()?;
// 写入元数据但保留原始修改时间
exiftool.write("photo.jpg")
.tag("Copyright", "© 2026")
.preserve_time(true)
.execute()?;Sourcepub fn quiet(self, yes: bool) -> Self
pub fn quiet(self, yes: bool) -> Self
静默模式
使用 -q 选项启用静默模式,减少输出信息。
可以使用多次来增加静默程度。
§示例
use exiftool_rs_wrapper::ExifTool;
let exiftool = ExifTool::new()?;
// 静默模式下写入
exiftool.write("photo.jpg")
.tag("Copyright", "© 2026")
.quiet(true)
.execute()?;Sourcepub fn zip_compression(self, yes: bool) -> Self
pub fn zip_compression(self, yes: bool) -> Self
启用 ZIP 压缩
使用 -z 选项读写压缩的元数据信息。
某些文件格式支持压缩元数据存储。
§示例
use exiftool_rs_wrapper::ExifTool;
let exiftool = ExifTool::new()?;
// 使用压缩写入元数据
exiftool.write("photo.jpg")
.tag("Copyright", "© 2026")
.zip_compression(true)
.execute()?;Sourcepub fn fix_base(self, offset: Option<u32>) -> Self
pub fn fix_base(self, offset: Option<u32>) -> Self
修复 MakerNotes 偏移
使用 -F 选项修复 MakerNotes 的基准偏移。
这在处理某些损坏或格式异常的图像文件时很有用。
§参数
offset- 可选的偏移量修正值(以字节为单位)
§示例
use exiftool_rs_wrapper::ExifTool;
let exiftool = ExifTool::new()?;
// 自动修复 MakerNotes 偏移
exiftool.write("photo.jpg")
.tag("Copyright", "© 2026")
.fix_base(None)
.execute()?;
// 指定偏移量修复
exiftool.write("photo.jpg")
.fix_base(Some(1024))
.execute()?;Sourcepub fn offset(self, tag: impl Into<String>, offset: impl Into<String>) -> Self
pub fn offset(self, tag: impl Into<String>, offset: impl Into<String>) -> Self
日期/时间偏移
示例: .offset("DateTimeOriginal", "+1:0:0 0:0:0") 表示增加 1 天
Sourcepub fn execute(self) -> Result<WriteResult>
pub fn execute(self) -> Result<WriteResult>
执行写入操作
Auto Trait Implementations§
impl<'et> Freeze for WriteBuilder<'et>
impl<'et> RefUnwindSafe for WriteBuilder<'et>
impl<'et> Send for WriteBuilder<'et>
impl<'et> Sync for WriteBuilder<'et>
impl<'et> Unpin for WriteBuilder<'et>
impl<'et> UnsafeUnpin for WriteBuilder<'et>
impl<'et> UnwindSafe for WriteBuilder<'et>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more