No commit activity in last 3 years
No release in over 3 years
A set of validators for image files. Currently it includes validators for image dimensions. See details in http://github.com/evedovelli/image_validators
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 3.0.0
~> 1.3
>= 0
>= 0
>= 0

Runtime

 Project Readme

Image Validators

Gem Version Build Status Code Climate

A set of validators for image files.

Installation

Add this line to your application's Gemfile:

gem 'image_validators'

And then execute:

$ bundle

Or install it yourself as:

$ gem install image_validators

Usage

In your model you have a image file attribute attached by using Paperclip:

class User < ActiveRecord::Base
  has_attached_file :photo, :styles => {:medium => "620x620>", :thumb => "200x200#"}

Validation of image dimensions

To validate the width and height of the image are greater or equal than 620x620, add to your model:

validates :image, :dimensions => {:greater_than_or_equal_to => {width: 620, height: 620}}

You can validate your image dimensions whith these operations: :less_than, :less_than_or_equal_to, :greater_than, :greater_than_or_equal_to, or :equal_to.

Optionally you can also specify an error message:

validates :image, :dimensions => {:equal_to => {width: 620}, :message => "Invalid image dimensions"}

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request