Created
January 5, 2012 18:36
-
-
Save jess/1566558 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
#carrierwave, get image width and height of image (using the MiniMagick gem) | |
#stick this in your uploader (ex: uploaders/file_uploader.rb) | |
def width | |
@image ||= get_minimagick_image | |
@image[:width] | |
end | |
def height | |
@image ||= get_minimagick_image | |
@image[:height] | |
end | |
def get_minimagick_image | |
MiniMagick::Image.open(Rails.root.join("public/#{self.url}")) | |
end | |
#now you can call it like this from anywhere | |
#file is my uploader object | |
@image = Image.find(1) | |
@image.file.height |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment