如何在Rails应用程序中使用mini_magick获取EXIF关键字? [英] How to get EXIF keywords using mini_magick in a Rails app?

查看:122
本文介绍了如何在Rails应用程序中使用mini_magick获取EXIF关键字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为具有EXIF关键字属性值的图像提取EXIF信息。我已经使用mini_magick成功读取了EXIF信息,只需打开图像并使用:

I am attempting to pull the EXIF information for images that have values for the EXIF "keywords" attribute. I have successfully read EXIF information using mini_magick by simply opening an image and using:

image["EXIF:Model"]

出于某种原因,以下所有内容都不会返回我知道的图像的关键字:

For some reason, none of the following will return keywords for an image that I know has them:

image["EXIF:Keywords"]
image["EXIF:XPKeywords"]
image["EXIF:Subject"]

我已使用此实用程序确认相关图像确实包含此信息: http://regex.info/exif.cgi

I have confirmed that the image in question does have this information using this utility: http://regex.info/exif.cgi

mini_magick只能访问某些EXIF值吗?看起来很奇怪,我可以访问某些EXIF信息但不能访问其他信息。

Does mini_magick only have access to certain EXIF values? It seems so odd that I can access certain EXIF information but not others.

推荐答案

EXIF元数据由相机创建,因此它仅包含技术相关内容。您真正想要访问的是 IPTC XMP

EXIF metadata is created by camera, therefore it contains only technical related stuff. What you actually want to access is IPTC and XMP.

Imagemagick,它位于mini_magick之后,允许阅读IPTC ,例如图片[%[IPTC:2:25]] 关键字(更新:了解性能问题,请参阅评论)。

Imagemagick, which is behind mini_magick, allows to read IPTC, e.g. image["%[IPTC:2:25]"] for keywords (update: be aware of perfomance issues, see comments).

至于XMP,我不知道一个简单的方法。您可以尝试运行

As for XMP, I don't know an easy way to do this. You can try to run

`identify -verbose #{your_filename}`

然后grub包含 xmp 的行。

and then grub lines that include xmp.

这篇关于如何在Rails应用程序中使用mini_magick获取EXIF关键字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆