Skip to content
This repository was archived by the owner on Jan 18, 2021. It is now read-only.

Commit 02ef0c0

Browse files
committedMay 3, 2011
code organized as a gem
1 parent 5df9cc1 commit 02ef0c0

7 files changed

+38
-3
lines changed
 

‎.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
pkg/*
2+
*.gem
3+
Gemfile.lock
4+
.bundle

‎Gemfile

39 Bytes
Binary file not shown.

‎README.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,16 @@ Requirements:
1313

1414
Installation:
1515
-------------
16+
- Install the gem
17+
18+
`gem install paperclip-facecrop'`
19+
1620
- Add to `Gemfile`
1721

18-
gem 'opencv'
19-
- Copy `paperclip/facecrop.rb` into your `lib` directory
22+
gem 'paperclip-facecrop'
23+
2024
- Write an initializer setting the path of the haarcascade filters(`initializers/paperclip.rb` for example):
2125

22-
require 'paperclip/facecrop'
2326
Paperclip::FaceCrop.classifiers = ["/usr/local/share/opencv/haarcascades/haarcascade_frontalface_alt_tree.xml"]
2427

2528
You can use more than one filter if you want in order to try more accurate searches.

‎Rakefile

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
require 'bundler'
2+
Bundler::GemHelper.install_tasks

‎paperclip/facecrop.rb ‎lib/paperclip-facecrop.rb

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
require 'opencv'
2+
13
class Paperclip::FaceCrop < Paperclip::Thumbnail
24

35
cattr_accessor :classifiers
@@ -10,6 +12,8 @@ def initialize(file, options = {}, attachment = nil)
1012
widths = []
1113
heights = []
1214

15+
raise "No classifiers were defined" if Paperclip::FaceCrop.classifiers.nil?
16+
1317
image = OpenCV::IplImage.load(file.path)
1418

1519
Paperclip::FaceCrop.classifiers.each do |classifier|

‎lib/version.rb

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class Paperclip
2+
class FaceCrop
3+
VERSION = "0.0.1"
4+
end
5+
end

‎paperclip-facecrop.gemspec

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# encoding: utf-8
2+
$:.push File.expand_path("../lib", __FILE__)
3+
require 'version'
4+
Gem::Specification.new do |s|
5+
s.name = "paperclip-facecrop"
6+
s.version = Paperclip::FaceCrop::VERSION
7+
s.authors = ["Borja Martín"]
8+
s.description = %q{Paperclip processor that is aware of the faces detected on the image so that they don't get cropped or aren't shown too small while generating the thumbnails}
9+
s.summary = %q{Paperclip processor that is aware of the faces found on the image}
10+
s.email = "borjam@dagi3d.net"
11+
s.homepage = "http://github.com/dagi3d/paperclip-facecrop"
12+
s.require_paths = ["lib"]
13+
s.files = `git ls-files`.split("\n")
14+
s.has_rdoc = false
15+
s.add_runtime_dependency("paperclip")
16+
s.add_runtime_dependency("opencv", "~> 0.0.6")
17+
end

0 commit comments

Comments
 (0)
This repository has been archived.