I want every single details from the file i upload.. i am using attachment_fu, and i want to know that when the image is been taken , what is ISO , and which model of camera were used ,, ,, In short i want all the detailed property of image ,, Is it possible ? how ?
+3
A:
The information you are looking is metadata called "Exif" (Exchangeable image file format), and is found in jpeg and tiff images. You can't find this in png or gif files.
There is an Exif gem that reads this metadata. You can find it (and its documentation) here.
The tricky part may be to get it to work together with attachment_fu. The easiest way to do this is most likely to create a callback in your model:
class Foo < ActiveRecord::Base
acts_as_attachment
after_attachment_saved do |record|
# do your exif stuff here using the Exif gem
end
end
vonconrad
2009-12-20 23:08:59
Thank s buddy , ur answer is usefull to me ,, i got it late but ur answer is perfact .We can use Rmagick for the use of EXIF too.
Arpit Vaishnav
2009-12-21 12:51:51
A:
@upload.save
image = Magick::ImageList.new("public/"+ @upload.public_filename)
@upload.date_taken = DateTime.strptime(image.get_exif_by_entry('DateTime')[0][1], "%Y:%m:%d %H:%M:%S")
@upload.model = image.get_exif_by_entry('model')[0][1]
@upload.camera = image.get_exif_by_entry('make')[0][1]
@upload.iso = image.get_exif_by_entry('ISOSpeedRatings')[0][1]
@upload.update_attributes(params[:@upload])
After saving any upload by rmaiggic and Exif we can get all the MEta data .. we can add all the details ,, and fro that on the top of the controller one has to write
require 'RMagick'
install gem name EXIF :: gem install exif image.get_exif_by_entry() will give all the functions available Thanks every one to help me Arpit
Arpit Vaishnav
2010-01-21 13:34:39