Location Paperclip::Processor
Extracts GeoLocation data from an image during Paperclip processing and attaches it to the associated model.
Installation
Add this line to your application's Gemfile:
gem 'paperclip-location'And then execute:
$ bundleOr install it yourself as:
$ gem install paperclip-locationUsage
Use it like any other Paperclip::Processor
class Place < ActiveRecord::Base
has_attached_file :photo, styles: { large: '600x600#' },
processors: [:thumbnail, :location]
endThe processor expects that the model in question has the following:
-
location_locked- a boolean flag to determine if the location has been manually overridden -
lat- a decimal representing the latitude -
lng- a decimal representing the longitude
If you don't have either, run a migration to add them
class AddLocationToPlaces < ActiveRecord::Migration
def self.change
add_column :places, :location_locked, :boolean, default: false, null: false
add_column :places, :lat, :decimal, precision: 10, scale: 15
add_column :places, :lng, :decimal, precision: 10, scale: 15
end
endThese field names will be customizable in future versions
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create new Pull Request