profound 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/README.md +9 -10
- data/bin/profound +24 -7
- data/lib/profound.rb +63 -2
- data/lib/profound/version.rb +1 -1
- data/profound.gemspec +1 -0
- metadata +23 -19
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0d7233a3beab83b29bea0ca38dd69b66e4e4fda5
|
4
|
+
data.tar.gz: 1e65a9c3b9fe3ba264be26fa35cb23591f2d0dea
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bc355208fb8b5f4cc5caa7427d009578d34ed5cbd869b0fb18cd9fa2310451fe347dd901f1d2b38f9a09d8b1fc251e1f2c3743659633b0e320c853b861570013
|
7
|
+
data.tar.gz: 9764519b9008083ecf12b89cf76fe42e71df6f811cda159fd3bfd8dfe8dcc4750afc7f05128a3d73ad0d8c6558452facec23e83afcab9066a752a81a8cec2728
|
data/README.md
CHANGED
@@ -1,24 +1,23 @@
|
|
1
1
|
# Profound
|
2
2
|
|
3
|
-
|
3
|
+
Create wallpapers like those on [theprofoundprogrammer](http://theprofoundprogrammer.com) even if you're aweful at Photoshop. It's based on *ImageMagick*.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
7
|
-
|
7
|
+
$ brew install imagemagick
|
8
|
+
$ gem install profound
|
8
9
|
|
9
|
-
|
10
|
+
## Usage
|
10
11
|
|
11
|
-
|
12
|
+
$ profound path/to/source.jpg "Complain about something" path/to/destination.jpg
|
12
13
|
|
13
|
-
|
14
|
+
The source can also be a few keywords to help find an image. You also specify the size of the image to find
|
14
15
|
|
15
|
-
|
16
|
+
$ profound --search-size=2880x1800 "road at night" "I hate cars" ~/profound-cars.jpg
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
## Usage
|
18
|
+
The source can also be omitted altogether. In that case, `profound` will search for images.
|
20
19
|
|
21
|
-
|
20
|
+
$ profound "Something ironic", ~/profound-ironic.jpg
|
22
21
|
|
23
22
|
## Contributing
|
24
23
|
|
data/bin/profound
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
require 'pry'
|
3
2
|
require 'optparse'
|
4
3
|
require File.expand_path('../../lib/profound', __FILE__)
|
5
4
|
|
6
5
|
|
7
6
|
options = {
|
8
|
-
:theme
|
7
|
+
:theme => :light,
|
8
|
+
:width => 1920,
|
9
|
+
:height => 1200
|
9
10
|
}
|
10
|
-
|
11
|
+
|
12
|
+
parser = OptionParser.new do |opts|
|
11
13
|
opts.banner = 'Usage: profound [options] source "Caption or label" destination'
|
12
14
|
opts.separator ""
|
13
15
|
opts.separator "Specific options:"
|
@@ -20,11 +22,26 @@ source, caption, destination = OptionParser.new do |opts|
|
|
20
22
|
options[:filter] = filter.to_sym
|
21
23
|
end
|
22
24
|
|
23
|
-
|
25
|
+
opts.on("--search-size=WIDTHxHEIGHT") do |size|
|
26
|
+
sizes = size.split("x")
|
27
|
+
options[:width] = sizes[0]
|
28
|
+
options[:height] = sizes[1]
|
29
|
+
end
|
30
|
+
|
31
|
+
opts.on("--font-family=FONT") do |font_family|
|
32
|
+
options[:font_family] = font_family
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
parser.parse!
|
37
|
+
|
38
|
+
if (2..3) === ARGV.length
|
39
|
+
source, caption, destination = (ARGV.length == 3 ? ARGV : [nil, *ARGV])
|
40
|
+
end
|
24
41
|
|
25
|
-
unless
|
26
|
-
puts
|
42
|
+
unless caption && destination
|
43
|
+
puts parser.to_s
|
27
44
|
exit(1)
|
28
45
|
end
|
29
46
|
|
30
|
-
Profound::Image.new(source, caption, options, destination).convert
|
47
|
+
Profound::Image.new(source, caption, options, destination).convert
|
data/lib/profound.rb
CHANGED
@@ -1,6 +1,14 @@
|
|
1
|
+
require 'rmagick'
|
2
|
+
require 'google-search'
|
3
|
+
require 'net/http'
|
4
|
+
require 'uri'
|
5
|
+
require 'tempfile'
|
6
|
+
|
1
7
|
require 'profound/version'
|
2
8
|
require 'profound/filters/toy_camera'
|
3
|
-
|
9
|
+
|
10
|
+
# convert original.jpg -size 460x -background transparent -fill black -pointsize 40 caption:'This is a multiline caption, This is a multiline caption, This is a multiline caption.' -gravity center -composite result.jpg
|
11
|
+
|
4
12
|
|
5
13
|
module Profound
|
6
14
|
class Theme
|
@@ -17,16 +25,64 @@ module Profound
|
|
17
25
|
end
|
18
26
|
end
|
19
27
|
|
28
|
+
class Input
|
29
|
+
class EmptyQueryResult < RuntimeError; end
|
30
|
+
|
31
|
+
Keywords = [
|
32
|
+
'forest', 'jungle', 'prairie', 'fields', 'flowers' 'beach', 'city', 'skyline',
|
33
|
+
'trail', 'lake', 'sky', 'sunrise', 'dawn', 'dusk', 'scenery', 'island', 'kitten', 'horse', 'puppy'
|
34
|
+
]
|
35
|
+
|
36
|
+
Qualifiers = [
|
37
|
+
'beautiful', 'gorgeous', 'magnificient', 'superb', nil
|
38
|
+
]
|
39
|
+
|
40
|
+
def initialize(source, options = {})
|
41
|
+
@source = source || [Qualifiers.sample, Keywords.sample].join(" ")
|
42
|
+
@options = options
|
43
|
+
end
|
44
|
+
|
45
|
+
def path
|
46
|
+
File.exists?(@source) ? @source : download
|
47
|
+
end
|
48
|
+
|
49
|
+
def download
|
50
|
+
image = search
|
51
|
+
|
52
|
+
response = Net::HTTP.get_response(URI.parse(image.uri))
|
53
|
+
|
54
|
+
tmp = Tempfile.new("profound")
|
55
|
+
tmp.write(response.body)
|
56
|
+
tmp.rewind
|
57
|
+
tmp.path
|
58
|
+
end
|
59
|
+
|
60
|
+
def search
|
61
|
+
query = [@source, [@options[:width], @options[:height]].compact.join("x")].join(" ")
|
62
|
+
image = Google::Search::Image.new(:query => query, :image_size => :huge, :file_type => :jpg).select{ |img|
|
63
|
+
(@options[:width].nil? || @options[:width].to_s == img.width.to_s) &&
|
64
|
+
(@options[:height].nil? || @options[:height].to_s == img.height.to_s)
|
65
|
+
}.sample
|
66
|
+
|
67
|
+
raise EmptyQueryResult, "Could not find images matching #{query}" unless image
|
68
|
+
|
69
|
+
image
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
20
73
|
class Image
|
21
74
|
include Profound::Filters::ToyCamera
|
22
75
|
|
23
76
|
def initialize(source, caption, options, destination)
|
77
|
+
source = Input.new(source, options).path
|
78
|
+
|
24
79
|
@source = Magick::ImageList.new(source).first
|
25
80
|
@target = Magick::ImageList.new
|
26
81
|
@destination = destination
|
27
82
|
@caption = caption
|
28
83
|
@options = options
|
29
84
|
@theme = Theme.new(options[:theme])
|
85
|
+
@font_family = options[:font_family] || 'Helvetica'
|
30
86
|
end
|
31
87
|
|
32
88
|
def convert
|
@@ -64,9 +120,11 @@ module Profound
|
|
64
120
|
text = Magick::Draw.new
|
65
121
|
|
66
122
|
color = @theme.color
|
123
|
+
font_family = @font_family
|
124
|
+
|
67
125
|
text.annotate(image, 0, 0, 0, 0, @caption) {
|
68
126
|
self.fill = color
|
69
|
-
self.font_family =
|
127
|
+
self.font_family = font_family
|
70
128
|
self.pointsize = 80
|
71
129
|
self.stroke_width = stroke_width
|
72
130
|
self.stroke = color
|
@@ -74,6 +132,9 @@ module Profound
|
|
74
132
|
}
|
75
133
|
|
76
134
|
image
|
135
|
+
rescue Magick::ImageMagickError => e
|
136
|
+
puts "An error has occured. Try installing ghostscript"
|
137
|
+
exit!
|
77
138
|
end
|
78
139
|
end
|
79
140
|
end
|
data/lib/profound/version.rb
CHANGED
data/profound.gemspec
CHANGED
metadata
CHANGED
@@ -1,20 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: profound
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.4
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Guillaume Malette
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-01-09 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rmagick
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
17
|
- - ~>
|
20
18
|
- !ruby/object:Gem::Version
|
@@ -22,15 +20,27 @@ dependencies:
|
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
24
|
- - ~>
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '2.13'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: google-search
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
30
41
|
- !ruby/object:Gem::Dependency
|
31
42
|
name: bundler
|
32
43
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
44
|
requirements:
|
35
45
|
- - ~>
|
36
46
|
- !ruby/object:Gem::Version
|
@@ -38,7 +48,6 @@ dependencies:
|
|
38
48
|
type: :development
|
39
49
|
prerelease: false
|
40
50
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
51
|
requirements:
|
43
52
|
- - ~>
|
44
53
|
- !ruby/object:Gem::Version
|
@@ -46,23 +55,20 @@ dependencies:
|
|
46
55
|
- !ruby/object:Gem::Dependency
|
47
56
|
name: rake
|
48
57
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
58
|
requirements:
|
51
|
-
- -
|
59
|
+
- - '>='
|
52
60
|
- !ruby/object:Gem::Version
|
53
61
|
version: '0'
|
54
62
|
type: :development
|
55
63
|
prerelease: false
|
56
64
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
65
|
requirements:
|
59
|
-
- -
|
66
|
+
- - '>='
|
60
67
|
- !ruby/object:Gem::Version
|
61
68
|
version: '0'
|
62
69
|
- !ruby/object:Gem::Dependency
|
63
70
|
name: rspec
|
64
71
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
72
|
requirements:
|
67
73
|
- - ~>
|
68
74
|
- !ruby/object:Gem::Version
|
@@ -70,7 +76,6 @@ dependencies:
|
|
70
76
|
type: :development
|
71
77
|
prerelease: false
|
72
78
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
79
|
requirements:
|
75
80
|
- - ~>
|
76
81
|
- !ruby/object:Gem::Version
|
@@ -97,26 +102,25 @@ files:
|
|
97
102
|
homepage: ''
|
98
103
|
licenses:
|
99
104
|
- MIT
|
105
|
+
metadata: {}
|
100
106
|
post_install_message:
|
101
107
|
rdoc_options: []
|
102
108
|
require_paths:
|
103
109
|
- lib
|
104
110
|
required_ruby_version: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
111
|
requirements:
|
107
|
-
- -
|
112
|
+
- - '>='
|
108
113
|
- !ruby/object:Gem::Version
|
109
114
|
version: '0'
|
110
115
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
|
-
none: false
|
112
116
|
requirements:
|
113
|
-
- -
|
117
|
+
- - '>='
|
114
118
|
- !ruby/object:Gem::Version
|
115
119
|
version: '0'
|
116
120
|
requirements: []
|
117
121
|
rubyforge_project:
|
118
|
-
rubygems_version:
|
122
|
+
rubygems_version: 2.0.14
|
119
123
|
signing_key:
|
120
|
-
specification_version:
|
124
|
+
specification_version: 4
|
121
125
|
summary: Creates images like those found on "The Profound Programmer"
|
122
126
|
test_files: []
|