dupe-magick 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0
1
+ 1.0.1
data/bin/dupes CHANGED
@@ -20,3 +20,4 @@ OptionParser.new do |opts|
20
20
 
21
21
  comparison = DupeMagick.new
22
22
  comparison.find_duplicates(options[:source_file], options[:target_path])
23
+
@@ -0,0 +1,65 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{dupe-magick}
8
+ s.version = "1.0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Tim Koopmans"]
12
+ s.date = %q{2010-11-15}
13
+ s.default_executable = %q{dupes}
14
+ s.description = %q{If you need to look for duplicates which can't otherwise be found via md5 checksums e.g. images of different formats or slightly lossy, then this gem can compare or find duplicates based on euclidian distances between points in an 8x8x8 RGB vector cube.}
15
+ s.email = %q{tim.koops@gmail.com}
16
+ s.executables = ["dupes"]
17
+ s.extra_rdoc_files = [
18
+ "LICENSE",
19
+ "README.rdoc"
20
+ ]
21
+ s.files = [
22
+ ".document",
23
+ ".gitignore",
24
+ "LICENSE",
25
+ "README.rdoc",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "bin/dupes",
29
+ "dupe-magick.gemspec",
30
+ "lib/dupe-magick.rb",
31
+ "lib/progressbar.rb",
32
+ "test/helper.rb",
33
+ "test/images/bright_wife.png",
34
+ "test/images/dark_wife.png",
35
+ "test/images/different.jpg",
36
+ "test/images/first_wife.png",
37
+ "test/images/second_wife.jpg",
38
+ "test/images/third_wife.jpg",
39
+ "test/results.html",
40
+ "test/test_dupe-magick.rb"
41
+ ]
42
+ s.homepage = %q{http://github.com/90kts/dupe-magick}
43
+ s.rdoc_options = ["--charset=UTF-8"]
44
+ s.require_paths = ["lib"]
45
+ s.rubygems_version = %q{1.3.7}
46
+ s.summary = %q{Detect image duplicates with RMagick}
47
+ s.test_files = [
48
+ "test/helper.rb",
49
+ "test/test_dupe-magick.rb"
50
+ ]
51
+
52
+ if s.respond_to? :specification_version then
53
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
54
+ s.specification_version = 3
55
+
56
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
57
+ s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
58
+ else
59
+ s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
60
+ end
61
+ else
62
+ s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
63
+ end
64
+ end
65
+
@@ -23,14 +23,19 @@ class DupeMagick
23
23
  source_image = process_image(source_file, {:geometry => '8x8!'})
24
24
  @source_vector = create_vector_from_image(source_image)
25
25
  @source_cube = create_cube_from_vector(@source_vector)
26
- files = files_in_directory(target_path)
26
+ files = Dir[target_path]
27
+ pbar = do_make_progress_bar("#{files.size} images", files.size)
28
+ results = {}
27
29
  files.each do |target|
28
30
  target_image = process_image(target, {:geometry => '8x8!'})
29
31
  @target_vector = create_vector_from_image(target_image)
30
32
  @target_cube = create_cube_from_vector(@target_vector)
31
33
  @distance = calculate_euclidian_distance(@source_cube, @target_cube)
32
- puts "Images are " + euclidian_plain_language(@distance) + ", score: " + @distance.to_i.to_s
34
+ results[target] = @distance
35
+ pbar.inc
33
36
  end
37
+ pbar.finish
38
+ write_results(source_file, results)
34
39
  end
35
40
 
36
41
  def serialize(obj)
@@ -49,10 +54,6 @@ class DupeMagick
49
54
  Magick::Image.read(file).first
50
55
  end
51
56
 
52
- def files_in_directory(path)
53
- Dir[path]
54
- end
55
-
56
57
  def do_make_progress_bar (title, total)
57
58
  ProgressBar.new(title, total)
58
59
  end
@@ -141,6 +142,15 @@ class DupeMagick
141
142
  end
142
143
  end
143
144
 
145
+ def write_results(source, results)
146
+ open("results.html", 'w') do |f|
147
+ f.puts "<img src='#{source}'>Source<hr>"
148
+ results.sort{|a,b| a[1]<=>b[1]}.each { |elem|
149
+ f.puts "<img src='#{elem[0]}' alt='#{elem[0]}'>#{elem[1]} => #{elem[0]}<br/>"
150
+ }
151
+ end
152
+ end
153
+
144
154
  end
145
155
 
146
156
 
@@ -0,0 +1,7 @@
1
+ <img src='/Users/koops/Code/dupe-magick/test/images/first_wife.png'>Source<hr>
2
+ <img src='/Users/koops/Code/dupe-magick/test/images/third_wife.jpg' alt='/Users/koops/Code/dupe-magick/test/images/third_wife.jpg'>0.0 => /Users/koops/Code/dupe-magick/test/images/third_wife.jpg<br/>
3
+ <img src='/Users/koops/Code/dupe-magick/test/images/second_wife.jpg' alt='/Users/koops/Code/dupe-magick/test/images/second_wife.jpg'>0.0 => /Users/koops/Code/dupe-magick/test/images/second_wife.jpg<br/>
4
+ <img src='/Users/koops/Code/dupe-magick/test/images/first_wife.png' alt='/Users/koops/Code/dupe-magick/test/images/first_wife.png'>0.0 => /Users/koops/Code/dupe-magick/test/images/first_wife.png<br/>
5
+ <img src='/Users/koops/Code/dupe-magick/test/images/bright_wife.png' alt='/Users/koops/Code/dupe-magick/test/images/bright_wife.png'>104.919016388832 => /Users/koops/Code/dupe-magick/test/images/bright_wife.png<br/>
6
+ <img src='/Users/koops/Code/dupe-magick/test/images/dark_wife.png' alt='/Users/koops/Code/dupe-magick/test/images/dark_wife.png'>138.101412013057 => /Users/koops/Code/dupe-magick/test/images/dark_wife.png<br/>
7
+ <img src='/Users/koops/Code/dupe-magick/test/images/different.jpg' alt='/Users/koops/Code/dupe-magick/test/images/different.jpg'>531.142165526331 => /Users/koops/Code/dupe-magick/test/images/different.jpg<br/>
@@ -37,5 +37,12 @@ class TestDupeMagick < Test::Unit::TestCase
37
37
  )
38
38
  end
39
39
 
40
+ should "parse a file path" do
41
+ comparison = DupeMagick.new
42
+ path = File.expand_path(File.dirname(__FILE__))
43
+ comparison.find_duplicates(path + "/" + "images/first_wife.png", path + "/" + "images/*")
44
+
45
+ end
46
+
40
47
 
41
48
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dupe-magick
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 0
10
- version: 1.0.0
9
+ - 1
10
+ version: 1.0.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Tim Koopmans
@@ -49,6 +49,7 @@ files:
49
49
  - Rakefile
50
50
  - VERSION
51
51
  - bin/dupes
52
+ - dupe-magick.gemspec
52
53
  - lib/dupe-magick.rb
53
54
  - lib/progressbar.rb
54
55
  - test/helper.rb
@@ -58,6 +59,7 @@ files:
58
59
  - test/images/first_wife.png
59
60
  - test/images/second_wife.jpg
60
61
  - test/images/third_wife.jpg
62
+ - test/results.html
61
63
  - test/test_dupe-magick.rb
62
64
  has_rdoc: true
63
65
  homepage: http://github.com/90kts/dupe-magick