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.
精彩评论