meme_captain 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +21 -0
- data/README.textile +21 -0
- data/lib/meme_captain.rb +40 -0
- data/meme_captain.gemspec +21 -0
- metadata +86 -0
data/COPYING
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2011 Matthew M. Boedicker
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.textile
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
This gem will create meme images like http://memegenerator.net/, but:
|
2
|
+
|
3
|
+
* will be more reliable
|
4
|
+
* will have a better API
|
5
|
+
* will be able to use your own images or any image from the web
|
6
|
+
|
7
|
+
<pre>
|
8
|
+
<code>
|
9
|
+
require 'meme_captain'
|
10
|
+
|
11
|
+
i = MemeCaptain.meme('luke300.jpeg', 'meme test', 'meme generator test')
|
12
|
+
i.display
|
13
|
+
|
14
|
+
require 'open-uri'
|
15
|
+
|
16
|
+
open('http://some_image_from_the_web.jpg', 'rb') do |f|
|
17
|
+
i = MemeCaptain.meme(f, 'test', '1 2 3')
|
18
|
+
i.write('out.jpg')
|
19
|
+
end
|
20
|
+
</code>
|
21
|
+
</pre>
|
data/lib/meme_captain.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'RMagick'
|
2
|
+
|
3
|
+
module MemeCaptain
|
4
|
+
|
5
|
+
module_function
|
6
|
+
|
7
|
+
def meme(path_or_io, line1, line2, options={})
|
8
|
+
img = Magick::ImageList.new
|
9
|
+
if path_or_io.respond_to?(:read)
|
10
|
+
img.from_blob(path_or_io.read)
|
11
|
+
else
|
12
|
+
img.read(path_or_io)
|
13
|
+
end
|
14
|
+
|
15
|
+
options = {
|
16
|
+
:fill => 'white',
|
17
|
+
:font => 'Impact-Regular',
|
18
|
+
:gravity => Magick::CenterGravity,
|
19
|
+
:size => "#{img.columns}x#{img.rows / 4}",
|
20
|
+
:stroke => 'black',
|
21
|
+
:stroke_width => 1,
|
22
|
+
:background_color => 'none',
|
23
|
+
}.merge(options)
|
24
|
+
|
25
|
+
line1_caption = Magick::Image.read("caption:#{line1.upcase}") {
|
26
|
+
options.each { |k,v| self.send("#{k}=", v) }
|
27
|
+
}
|
28
|
+
|
29
|
+
line2_caption = Magick::Image.read("caption:#{line2.upcase}") {
|
30
|
+
options.each { |k,v| self.send("#{k}=", v) }
|
31
|
+
}
|
32
|
+
|
33
|
+
img[0].composite!(line1_caption[0], Magick::NorthGravity,
|
34
|
+
Magick::OverCompositeOp)
|
35
|
+
|
36
|
+
img[0].composite!(line2_caption[0], Magick::SouthGravity,
|
37
|
+
Magick::OverCompositeOp)
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
$:.unshift(File.join(File.dirname(__FILE__), 'lib'))
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = 'meme_captain'
|
7
|
+
s.version = '0.0.1'
|
8
|
+
s.summary = 'create meme images'
|
9
|
+
s.description = s.summary
|
10
|
+
s.homepage = 'https://github.com/mmb/meme_captain'
|
11
|
+
s.authors = ['Matthew M. Boedicker']
|
12
|
+
s.email = %w{matthewm@boedicker.org}
|
13
|
+
|
14
|
+
s.required_rubygems_version = '>= 1.3.6'
|
15
|
+
|
16
|
+
%w{
|
17
|
+
rmagick
|
18
|
+
}.each { |g| s.add_dependency g }
|
19
|
+
|
20
|
+
s.files = `git ls-files`.split("\n")
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: meme_captain
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Matthew M. Boedicker
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-04-14 00:00:00 -04:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: rmagick
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
35
|
+
description: create meme images
|
36
|
+
email:
|
37
|
+
- matthewm@boedicker.org
|
38
|
+
executables: []
|
39
|
+
|
40
|
+
extensions: []
|
41
|
+
|
42
|
+
extra_rdoc_files: []
|
43
|
+
|
44
|
+
files:
|
45
|
+
- COPYING
|
46
|
+
- README.textile
|
47
|
+
- lib/meme_captain.rb
|
48
|
+
- meme_captain.gemspec
|
49
|
+
has_rdoc: true
|
50
|
+
homepage: https://github.com/mmb/meme_captain
|
51
|
+
licenses: []
|
52
|
+
|
53
|
+
post_install_message:
|
54
|
+
rdoc_options: []
|
55
|
+
|
56
|
+
require_paths:
|
57
|
+
- lib
|
58
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
59
|
+
none: false
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
hash: 3
|
64
|
+
segments:
|
65
|
+
- 0
|
66
|
+
version: "0"
|
67
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
|
+
none: false
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
hash: 23
|
73
|
+
segments:
|
74
|
+
- 1
|
75
|
+
- 3
|
76
|
+
- 6
|
77
|
+
version: 1.3.6
|
78
|
+
requirements: []
|
79
|
+
|
80
|
+
rubyforge_project:
|
81
|
+
rubygems_version: 1.5.2
|
82
|
+
signing_key:
|
83
|
+
specification_version: 3
|
84
|
+
summary: create meme images
|
85
|
+
test_files: []
|
86
|
+
|