且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

优化图像一次,避免再次执行

更新时间:2023-11-14 08:42:40

你可以使用扩展属性,它们是元数据并存储在文件系统中。使用 xattr 读取和写入它们:

You could use "extended attributes" which are metadata and stored in the filesystem. Read and write them with xattr:

# Read existing attributes
xattr -l image.png

# Set an optimised flag of your own invention/description
xattr -w optimised true image.png

# Read attributes again
xattr -l image.png
optimised: true

存在可以在长列表中检测到扩展属性 - 在权限之后是 @ 符号:

The presence of an extended attribute can be detected in a long listing - it is the @ sign after the permissions:

-rw-r--r--@ 1 mark  staff  275 29 May 07:54 image.png

正如您在评论中提到的那样,请确保您使用的任何备份程序都遵守这些属性,然后再将其作为策略提交。 FAT-32文件系统在这种情况下是出了名的穷人 - 虽然 tar 文件或类似文件可能会在Windows-land和back之后幸存下来。

As you allude in your comments, make sure that any backup programs you use honour the attributes before committing to it as a strategy. FAT-32 filesystems are notoriously poor at this sort of thing - though tar file or similar may survive a trip to Windows-land and back.

作为替代方案,只需在EXIF标题中设置注释 - 我已在这个相关答案......

As an alternative, just set a comment in the EXIF header - I have already covered that in this related answer...