I need to check if the images people upload to my site have the exact width of 200px and height of 300px. If they haven't got those dimensions, they shouldn't be saved in the database.
I've tried for ages with mini-magick and gone through numerous tutorials, posts on Stack Overflow, etc. but I can't find a functional way of doing this.
I'm using ruby 1.9.3 and rails 3.2.2, on a mongoDB running mongoid.
Was really hoping you could put me in the right direction.
My image model look like this:
class Flow
include Mongoid::Document
include Mongoid::Taggable
include Mongoid::Timestamps
include Mongo::Voteable
voteable self, :up => +1, :down => -1
attr_accessible :image, :remote_image_url, :tags
mount_uploader :image, UserUploader
belongs_to :user
field :shot, :type => String
field :remote_image_url, :type => String
field :tags, type: Array
end
And my carrierwave model looks like this:
class UserUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
storage :fog
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
def extension_white_list
%w(jpg jpeg png gif)
end
end