gpt4 book ai didi

python - 使用 Python 检索图像描述(不通过 PIL 或 exifread 在 EXIF 数据中返回)

转载 作者:行者123 更新时间:2023-12-04 01:08:32 25 4
gpt4 key购买 nike

我想获取 .jpg 图像的描述。它显示在 Mac OSx 信息 (cmd +i) 窗口中。

Mac OS Info

我想阅读“描述”(德语为 Beschreibung)字段。用 PIL 和 exifread 尝试这个没有成功。

我可以获得这些 exif 标签,但它们不包含描述或关键字。

Key: Image ImageWidth
Key: Image ImageLength
Key: Image Compression
Key: Image Make
Key: Image Model
Key: Image XResolution
Key: Image YResolution
Key: Image PlanarConfiguration
Key: Image ResolutionUnit
Key: Image Software
Key: Image DateTime
Key: Image YCbCrPositioning
Key: Image ExifOffset
Key: Thumbnail Compression
Key: Thumbnail Orientation
Key: Thumbnail XResolution
Key: Thumbnail YResolution
Key: Thumbnail ResolutionUnit
Key: Thumbnail DateTime
Key: Thumbnail JPEGInterchangeFormat
Key: Thumbnail JPEGInterchangeFormatLength
Key: EXIF ExposureTime
Key: EXIF FNumber
Key: EXIF ExposureProgram
Key: EXIF ISOSpeedRatings
Key: EXIF SensitivityType
Key: EXIF ExifVersion
Key: EXIF DateTimeOriginal
Key: EXIF DateTimeDigitized
Key: EXIF ComponentsConfiguration
Key: EXIF ShutterSpeedValue
Key: EXIF ApertureValue
Key: EXIF ExposureBiasValue
Key: EXIF MaxApertureValue
Key: EXIF MeteringMode
Key: EXIF LightSource
Key: EXIF Flash
Key: EXIF FocalLength
Key: EXIF SubSecTimeOriginal
Key: EXIF SubSecTimeDigitized
Key: EXIF ColorSpace
Key: EXIF ExifImageWidth
Key: EXIF ExifImageLength
Key: EXIF FocalPlaneXResolution
Key: EXIF FocalPlaneYResolution
Key: EXIF FocalPlaneResolutionUnit
Key: EXIF SensingMethod
Key: EXIF FileSource
Key: EXIF SceneType
Key: EXIF CVAPattern
Key: EXIF CustomRendered
Key: EXIF ExposureMode
Key: EXIF WhiteBalance
Key: EXIF DigitalZoomRatio
Key: EXIF FocalLengthIn35mmFilm
Key: EXIF SceneCaptureType
Key: EXIF GainControl
Key: EXIF Contrast
Key: EXIF Saturation
Key: EXIF Sharpness
Key: EXIF SubjectDistanceRange
Key: EXIF BodySerialNumber
Key: EXIF LensSpecification
Key: EXIF LensModel

我假设这些字段不是 EXIF 数据?我需要寻找什么才能获得描述?

最佳答案

感谢@Mark Serchells 的回答,我发现描述不是EXIF 数据而是IPTC 数据(exiftool 显示所有字段)。

在 Python 中,我现在可以使用 IPTCInfo3:https://pypi.org/project/IPTCInfo3/并通过以下方式提取描述:

info = IPTCInfo('img.jpg')
info['caption/abstract']

打印:

b'Gel\xe4ndewagen auf den Salzformationen im Salzsee Ass-Ale in der Danakil-Senke, Danakil-Senke, Hamed Ela, Wollo, \xc4thiopien, Afrika

关于python - 使用 Python 检索图像描述(不通过 PIL 或 exifread 在 EXIF 数据中返回),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65550956/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com