使用 Minimagick 获取 Carrierwave 中的 EXIF 数据
嘿。我一直在尝试使用 MiniMagick 从通过 Carrierwave 上传的图像中获取一些 EXIF 数据。我进行了相当广泛的搜索,试图找出答案,但找不到任何相关的内容。有人知道怎么做吗?谢谢!
Hey. I've been trying to get some EXIF data out of the images I've uploaded via Carrierwave with MiniMagick. I've searched quite extensively trying to figure it out but I can't find anything relavent. Anyone know how? Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
想通了。以下代码块将向 Carrierwave 上传器添加一个 get_exif 方法,
只需将 EXIF 名称(例如“DateTimeOriginal”)传递给它,它就会返回数据。
但要记住的一件事是,如果您将 Mongoid 与 GridFS 一起使用,或任何其他不提供 current_path 的东西,请进行操作!取决于它。对于 Mongoid,您可以创建一个临时文件并为其提供该路径,或者切换到文件存储而不是 GridFS。
Figured it out. The following code block will add a method get_exif to a Carrierwave uploader
Just pass the EXIF name such as "DateTimeOriginal" to it, and it will return the data.
One thing to keep in mind however is that if you are using Mongoid with GridFS, or anything else that doesn't provide current_path, manipulate! depends upon it. For Mongoid you can either make a temp file and give it that path, or switch to file storage instead of GridFS.