Google 最近更改了网站的图片要求,称它们应包含 IPTC 图片版权元数据。
https://developers.google.com/search/docs/advanced/appearance/image-rights-metadata
我已经成功地能够使用 EXIFTOOL 为我的 SQL 表中的 jpg 图像更新图像 XMP、EXIF 和 IPTC 元数据,以满足这些新的 google 要求。
我在 IPTC 工具上检查了测试图像,它确实包含所需的 XMP、EXIF 和 IPTC 元数据。
https://getpmd.iptc.org/getiptcpmd.html
然而…………
大量读取WEBP格式和exiv2、dwebp、webpmux等工具,只能将XMP和EXIF元数据写入webp图片。
https://www.exiv2.org/manpage.html
https://developers.google.com/speed/webp/docs/cwebp
https://developers.google.com/speed/webp/docs/webpmux
https://image.online-convert.com/convert-to-webp (drag and drop web tool that converts Jpg to webp with XMP & Exif metadata)
似乎 webp 不支持 IPTC 元数据,因此不满足这些要求:
https://developers.google.com/search/docs/advanced/appearance/image-rights-metadata
结论:
- Webp 作为我希望 google 索引的图像的图像格式,是一个死鸭子,除非/直到 google 修改 RIFF 标头以包含 IPTC。
- 接下来的步骤是将我网站上的图片恢复为 jpg。
对于任何对我如何从 php 修改图像 XMP、EXIF 和 IPTC 元数据感兴趣的人。
a) 这些是我最终决定使用 exiftool 命令更新它们的元数据字段。
exiftool -iptc:by-line="image creator" A0000-01.jpg
exiftool -xmp:creator="image creator" A0000-01.jpg
exiftool -exif:Artist="image creator" A0000-01.jpg
exiftool -iptc:CopyrightNotice="Copywrite 2022 websiteName.com" A0000-01.jpg
exiftool -xmp:rights="Copywrite 2022 websiteName.com" A0000-01.jpg
exiftool -exif:Copyright="Copywrite 2022 websiteName.com" A0000-01.jpg
exiftool -iptc:keywords="keyword1,keyword2,keyword3" A0000-01.jpg
exiftool -xmp:Subject="keyword1,keyword2,keyword3" A0000-01.jpg
exiftool -exif:UserComment="keyword1,keyword2,keyword3" A0000-01.jpg
exiftool -iptc:credit="image reproduced with permission from" A0000-01.jpg
exiftool -xmp:credit="image reproduced with permission from" A0000-01.jpg
exiftool -iptc:ObjectName="Image title" A0000-01.jpg
exiftool -xmp:Title="Image title" A0000-01.jpg
exiftool -iptc:Caption-Abstract="Image description" A0000-01.jpg
exiftool -xmp:description="Image description" A0000-01.jpg
exiftool -exif:ImageDescription="Image description" A0000-01.jpg
exiftool -iptc:Source="Url where image can be found" A0000-01.jpg
exiftool -xmp:Source="Url where image can be found" A0000-01.jpg
exiftool -exif:gpslatitude="44.081102" -exif:gpslatituderef=N A0000-01.jpg
exiftool -exif:gpslongitude="-35.489600" -exif:gpslongituderef=W A0000-01.jpg
exiftool -xmp:gpslatitude="44.081102 N" A0000-01.jpg
exiftool -gpslongitude="-35.489600 E" A0000-01.jpg
exiftool -xmp:AuthorsPosition="website owner & coder" A0000-01.jpg
exiftool -iptc:By-lineTitle="website owner & coder" A0000-01.jpg
exiftool -xmp:CaptionWriter="websiteName.com.com" A0000-01.jpg
exiftool -iptc:Writer-Editor="websiteName.com.com" A0000-01.jpg
b) 在 php 中,我使用以下代码生成包含 exiftool 命令的文本字符串:
$F_XmpDescriptionSt = 'exiftool -xmp:description="'.$iptcDescription.'" "'.$absoluteImgJpgFullSizePath.'"';
其中 $iptcDescription 和 $absoluteImgJpgFullSizePath 是 mySQL 表中所需的元数据值
c) 然后我通过命令提示符终端使用以下代码启动命令:
$FullsizeExiftoolXmpDescriptionExecute = exec("$F_XmpDescriptionSt");
我对要更新的所有元数据字段重复上述操作,将 php 代码调整为 exiftool 命令。
我确信有一种更优雅的方式来执行此操作,例如批处理脚本?但我更喜欢将每个 exiftool 命令作为一行代码一个接一个地启动,以便为我更新的每个元数据字段获得响应消息“1 个文件已更新”。完成所有元数据字段的代码大约需要 15 秒,所以问题不大。
这行代码输出包含在变量 FullsizeExiftoolXmpDescriptionExecute 中的 exiftool 响应。
<h4>Fullsize XMP Description $FullsizeExiftoolXmpDescriptionExecute to $iptcDescription</h4>
本视频教程介绍了如何在 Windows 10 上安装 exiftool。
https://www.youtube.com/watch?v=Ku1Nx-kl7RM