Retrieving EXIF ​​data in Carrierwave with Minimagick

Hey. I am trying to get some EXIF ​​data from images that I uploaded via Carrierwave using MiniMagick. I searched pretty broadly, trying to figure it out, but I can't find anything suitable. Does anyone know how? Thanks!

+4
source share
1 answer

Figured it out. The following code block will add the get_exif method to the Carrierwave loader

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

Just pass it the name EXIF, for example "DateTimeOriginal", and it will return the data.

It is one thing to keep in mind, however, that if you are using Mongoid with GridFS or something else that current_path does not provide, manipulate! depends on it. For Mongoid, you can either create a temporary file, or transfer it to this path, or switch to the file storage instead of GridFS.

+5
source

Source: https://habr.com/ru/post/1339814/


All Articles