ruby - 如何从 URL 读取图像元数据?

标签 ruby image amazon-s3 metadata

我想读取 S3 上已上传的 JPEG 的元数据。有没有办法在不在本地下载文件的情况下在 Ruby 中执行此操作?

我面临的问题是 Image(Mini)Magick 没有将 URL 作为源(或者至少我没有找到正确的命令)。

更新:

这是有效的:

>> image = MiniMagick::Image.from_file -path_to_file-
>> image["EXIF:datetime"]
=> "2010:07:19 23:07:54"

但我没有找到一个很好的替代“from_file”的网址,比如:

>> image = MiniMagick::Image.from_url http://image_adress.com/image.jpg

不起作用。

最佳答案

使用 open-uri 怎么样?

require 'open-uri'

image = nil
open('http://image_adress.com/image.jpg') do |file|
  image = MiniMagick::Image.from_blob(file.read) rescue nil
end
image["EXIF:datetime"] if image

关于ruby - 如何从 URL 读取图像元数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3408391/

相关文章:

ruby-on-rails - 如何在Ruby中获取目录中文件的总大小

css - Windows 上的 Sass(Ruby CSS 压缩器)绝对路径参数

mysql - 如何从旧的(非 ruby​​)应用程序获取数据到新的(ruby)应用程序?

ruby-on-rails - 格式化 Authlogic "last_login_at"字符串

html - 箭头纯 CSS 图像 slider

javascript - 传单:在初始 View 上移动 map

php - AWS S3 PHP 进度条(服务器到云)

ruby-on-rails - 创建 Rails 音乐播放器应用程序(类似于 Rdio)

objective-c - 使用UIWebView调用Upload方法

image - 如何提高图像的强度对比度?