Warm tip: This article is reproduced from serverfault.com, please click

其他-获取Rust中图像的文件大小

(其他 - Get File Size of Image in Rust)

发布于 2020-11-29 08:46:15

如何使用锈迹中的图像箱确定图像的文件大小?

let img = image::open("imgs/2.jpg").unwrap();
let myBytes = &img.to_bytes();
//get the number of bytes?
Questioner
ANimator120
Viewed
12
Alexey Larionov 2020-11-29 17:09:11

image板条箱处理图像,让标准库的fs模块处理文件系统:

let imgSize = std::fs::metadata("imgs/2.jpg").unwrap().len();

还要寻找std::fs::Metadatastruct的其他功能