Created
May 30, 2010 07:14
-
-
Save rrichards/418849 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Your resizing will warp (squash or stretch) images if they don't match | |
# your dimensions. | |
#To resize while maintaining aspect ratio, use "64x64>" - This will | |
#result in either the width or the height = 64 and the other side will | |
#be relatively smaller. | |
#To resize with crop, use "64x64#" - This will result in both width and | |
#height = 64 and the longer of the two will be cropped evenly on either | |
#side. | |
#You should usually use one of these unless you are very sure of the | |
#aspect ratio of the images being uploaded. | |
has_attached_file :photo, | |
:styles => { | |
:original => "700x700#", | |
:large => "433x433#", | |
:medium => "150x150#", | |
:thumb => "68x68#" | |
} | |
#... | |
# Callback after styles processing (thumbnails). | |
# Use this to extract Exif metadata from the image | |
def post_process_photo | |
# only works with jpgs | |
if photo.content_type == 'image/jpeg' || 'image/pjpeg' | |
img_meta = EXIFR::JPEG.new(photo.queued_for_write[:original].path) | |
return unless img_meta | |
#logger.debug "Photo EXIF: #{img_meta.inspect}" | |
self.camera_model = img_meta.model | |
self.exposure_time = img_meta.exposure_time.to_s | |
self.f_number = img_meta.f_number.to_s | |
self.taken_at = img_meta.date_time | |
# also have width and height. See http://exifr.rubyforge.org/api/index.html for details | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment