Calculating an Images Orientation using Paperclip
Thursday, June 10th, 2010If you ever need to know if an image is portrait or landscape in orientation, you can do the following (assuming you have an orientation attribute on your model:
class Image < ActiveRecord::Base
# Paperclip
has_attached_file :file
# Callbacks
before_create :set_orientation
protected
def set_orientation
original_file = self.file.to_file(:original)
[...]
Posted in Ruby on Rails | Tags: paperclip, Ruby, Ruby on Rails | Comments


