开发者

Getting EXIF data in Carrierwave with Minimagick

开发者 https://www.devze.com 2023-02-11 02:37 出处:网络
Hey. I\'ve been trying to get some EXIF data out of the images I\'ve upload开发者_StackOverflow中文版ed via Carrierwave with MiniMagick. I\'ve searched quite extensively trying to figure it out but I

Hey. I've been trying to get some EXIF data out of the images I've upload开发者_StackOverflow中文版ed 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!


Figured it out. The following code block will add a method get_exif to a Carrierwave uploader

def get_exif( name )
  manipulate! do |img|
    return img["EXIF:" + name]
  end
end

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号