Skip to content

Instantly share code, notes, and snippets.

@jbmyid
Created June 20, 2014 07:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbmyid/2e0405f1540154df7a6e to your computer and use it in GitHub Desktop.
Save jbmyid/2e0405f1540154df7a6e to your computer and use it in GitHub Desktop.
process :get_geometry
def geometry
@geometry
end
def get_geometry
if (@file)
img = ::Magick::Image::read(@file.file).first
@geometry = [ img.columns, img.rows ]
end
end
#User class
validate :validate_minimum_image_size
def validate_minimum_image_size
geometry = self.image.geometry
if (! geometry.nil?)
self.width = geometry[0]
self.height = geometry[1]
end
unless (self.width == 320 && self.height == 480) || (self.width == 640 && self.height == 960)
errors.add :base, "Naughty you... iPhone designs should be 320px x 480px or 640px x 960px."
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment