lgtm_hd 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +52 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +4 -0
- data/LICENSE +21 -0
- data/LICENSE.txt +21 -0
- data/README.md +55 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/lgtm_hd +4 -0
- data/bin/setup +7 -0
- data/fonts/impact.ttf +0 -0
- data/images/example_1_after.gif +0 -0
- data/images/example_1_before.gif +0 -0
- data/images/example_2_after.jpg +0 -0
- data/images/example_2_before.png +0 -0
- data/lgtm_hd.gemspec +39 -0
- data/lib/lgtm_hd.rb +119 -0
- data/lib/lgtm_hd/cli.rb +62 -0
- data/lib/lgtm_hd/configuration.rb +20 -0
- data/lib/lgtm_hd/version.rb +3 -0
- metadata +193 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 70dc66e657f36492cba7d2ab4d499ecadc3a9844
|
4
|
+
data.tar.gz: a1640c33d4b8dc485942c5c3def55eb3610adc36
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 95b3fafc218b4c4ff43482c59ec75e9c25c87f64d07dc317e2d7de601f171c4190ad41e19a1c74457c4b602c8d63a0585766317a022ab06c0bfe117657309f46
|
7
|
+
data.tar.gz: fe2e5eeb2c373c414ad4d5405bcf824203e4cc601eb73c0c2330c3a31a2a33865e4904533a946562860816c19a7e799bc7b2d69deb44f70f771a836ef5a9222d
|
data/.gitignore
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
|
2
|
+
*.gem
|
3
|
+
*.rbc
|
4
|
+
/.config
|
5
|
+
/coverage/
|
6
|
+
/InstalledFiles
|
7
|
+
/pkg/
|
8
|
+
/spec/reports/
|
9
|
+
/spec/examples.txt
|
10
|
+
/test/tmp/
|
11
|
+
/test/version_tmp/
|
12
|
+
/tmp/
|
13
|
+
|
14
|
+
# Used by dotenv library to load environment variables.
|
15
|
+
# .env
|
16
|
+
|
17
|
+
## Specific to RubyMotion:
|
18
|
+
.dat*
|
19
|
+
.repl_history
|
20
|
+
build/
|
21
|
+
*.bridgesupport
|
22
|
+
build-iPhoneOS/
|
23
|
+
build-iPhoneSimulator/
|
24
|
+
|
25
|
+
## Specific to RubyMotion (use of CocoaPods):
|
26
|
+
#
|
27
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
28
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
29
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
30
|
+
#
|
31
|
+
# vendor/Pods/
|
32
|
+
|
33
|
+
## Documentation cache and generated files:
|
34
|
+
/.yardoc/
|
35
|
+
/_yardoc/
|
36
|
+
/doc/
|
37
|
+
/rdoc/
|
38
|
+
|
39
|
+
## Environment normalization:
|
40
|
+
/.bundle/
|
41
|
+
/vendor/bundle
|
42
|
+
/lib/bundler/man/
|
43
|
+
|
44
|
+
# for a library or gem, you might want to ignore these files since the code is
|
45
|
+
# intended to run in multiple environments; otherwise, check them in:
|
46
|
+
Gemfile.lock
|
47
|
+
.ruby-version
|
48
|
+
.ruby-gemset
|
49
|
+
|
50
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
51
|
+
.rvmrc
|
52
|
+
|
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
+
|
9
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
+
|
11
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
+
|
13
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2017 Phradion
|
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 all
|
13
|
+
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 THE
|
21
|
+
SOFTWARE.
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Huy Dinh
|
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.md
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
# LgtmHd
|
2
|
+
[![Build Status](https://travis-ci.org/phradion/lgtm_hd.svg?branch=master)](https://travis-ci.org/phradion/lgtm_hd)
|
3
|
+
[![Code Climate](https://codeclimate.com/github/phradion/lgtm_hd/badges/gpa.svg)](https://codeclimate.com/github/phradion/lgtm_hd)
|
4
|
+
[![Test Coverage](https://codeclimate.com/github/phradion/lgtm_hd/badges/coverage.svg)](https://codeclimate.com/github/phradion/lgtm_hd/coverage)
|
5
|
+
|
6
|
+
This game is for LGTM lovers that want to generate cool shits without leaving their terminal.
|
7
|
+
|
8
|
+
Check out the magic below
|
9
|
+
|
10
|
+
Source | Kawaii!
|
11
|
+
:-------------------------:|:-------------------------:
|
12
|
+
![](./images/example_1_before.gif?raw=true) | ![](./images/example_1_after.gif?raw=true)
|
13
|
+
|
14
|
+
Source | Happy Taeyeon!
|
15
|
+
:-------------------------:|:-------------------------:
|
16
|
+
![](./images/example_2_before.png?raw=true) | ![](./images/example_2_after.jpg?raw=true)
|
17
|
+
|
18
|
+
## Installation
|
19
|
+
$ gem install lgtm_hd
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
$ lgtm_hd <source> <output> [--clipboard]
|
23
|
+
$ lgtm_hd http://domain.com/image.jpg /path/lgtm.jpg
|
24
|
+
|
25
|
+
## Features
|
26
|
+
* Smart Color - render White or Black caption based on the background's darkness
|
27
|
+
* Source Image - Support Offline (file) or Online (url)
|
28
|
+
* Caption Position - Top Center or Bottom Center positions for the caption
|
29
|
+
* Auto Clipboard - MacOSX user can just paste directly to comment box on Github after running the programm. On other OSes the clipboard only returns the path to the generated LGTM image.
|
30
|
+
* Formats - GIF, PNG, JPEG (SVG and TIFF not tested yet)
|
31
|
+
* Max Image size is 500px by 500px
|
32
|
+
## TODO List
|
33
|
+
* Add options for [font size, positions] (Code already setup for this, expect new version soon!)
|
34
|
+
* Add --source-random option incase there is no source provided.
|
35
|
+
* Add --caption-color for more colorful captions
|
36
|
+
* Integrate with lgtm.in or google images
|
37
|
+
* Submission to lgtm.in
|
38
|
+
* Query lgtm or google images and return the first found item
|
39
|
+
* Interactive mode with image preview in ASCII generation
|
40
|
+
* Interactive mode that allow adjusting LGTM captions
|
41
|
+
* Add progress bar for the whole generation process
|
42
|
+
* Support multiple LGTM texts
|
43
|
+
|
44
|
+
## Contributing
|
45
|
+
As I am new in Ruby. Please feel free to help me improving this gem in whatever way you want, for examples, code contributing, code reviewing, manual testing or even just brushing up ideas :)
|
46
|
+
|
47
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/phradion/lgtm_hd. Of course as long as you follow the [Contributor Covenant](contributor-covenant.org) code of conduct.
|
48
|
+
|
49
|
+
|
50
|
+
## License
|
51
|
+
|
52
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
53
|
+
|
54
|
+
## About Me
|
55
|
+
Ruby Newbie and Chandler Bing's big fan.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "lgtm_hd"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/lgtm_hd
ADDED
data/bin/setup
ADDED
data/fonts/impact.ttf
ADDED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/lgtm_hd.gemspec
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
ROOT_DIR = __dir__
|
5
|
+
require 'lgtm_hd/version'
|
6
|
+
require 'rubygems/dependency_installer.rb'
|
7
|
+
|
8
|
+
Gem::Specification.new do |spec|
|
9
|
+
spec.name = "lgtm_hd"
|
10
|
+
spec.version = LgtmHD::VERSION
|
11
|
+
spec.authors = ["Huy Dinh"]
|
12
|
+
spec.email = ["phradion@gmail.com"]
|
13
|
+
|
14
|
+
spec.summary = %q{Generating LGTM image to clipboard.}
|
15
|
+
spec.description = %q{Generating images from user input with LGTM text on it, or fetching images from LGTM.in based on user's query. Finally put the image to clipboard.}
|
16
|
+
spec.homepage = "http://github.com/phradion/lgtm_hd"
|
17
|
+
spec.license = "MIT"
|
18
|
+
|
19
|
+
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
20
|
+
# delete this section to allow pushing this gem to any host.
|
21
|
+
# if spec.respond_to?(:metadata)
|
22
|
+
# spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
23
|
+
# else
|
24
|
+
# raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
25
|
+
# end
|
26
|
+
|
27
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
28
|
+
spec.bindir = "bin"
|
29
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }.reject { |f| f.match(%r{^(console|setup)/}) }
|
30
|
+
spec.require_paths = ["lib"]
|
31
|
+
|
32
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
33
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
34
|
+
spec.add_development_dependency "rspec", "~> 3.6", ">= 3.6.0"
|
35
|
+
spec.add_runtime_dependency "commander", "~> 4.4", ">= 4.4.3"
|
36
|
+
spec.add_runtime_dependency "clipboard", "~> 1.1", ">= 1.1.1"
|
37
|
+
spec.add_runtime_dependency "os", "~> 1.0", ">= 1.0.0"
|
38
|
+
spec.add_runtime_dependency "mini_magick", "~> 4.7"
|
39
|
+
end
|
data/lib/lgtm_hd.rb
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
require "lgtm_hd/configuration"
|
2
|
+
require "mini_magick"
|
3
|
+
require "rubygems"
|
4
|
+
|
5
|
+
module LgtmHD
|
6
|
+
|
7
|
+
class MemeGenerator
|
8
|
+
attr_accessor :input_image_URI, :output_image_URI
|
9
|
+
|
10
|
+
# TODO make options list for this class
|
11
|
+
# TODO pass BLOB data into this class instead of paths
|
12
|
+
def initialize(input_image_URI, output_image_URI)
|
13
|
+
@input_image_URI = input_image_URI
|
14
|
+
@output_image_URI = output_image_URI
|
15
|
+
|
16
|
+
@img = MiniMagick::Image.open(@input_image_URI)
|
17
|
+
@caption_position = :caption_position_bottom
|
18
|
+
end
|
19
|
+
|
20
|
+
##
|
21
|
+
# Used to create a new Image object data-copy. Not used to "paint" or
|
22
|
+
# that kind of thing.
|
23
|
+
#
|
24
|
+
# @param caption_text [String] Specify the caption for your LGTM meme
|
25
|
+
# @return [MiniMagick::Image] The drawn image
|
26
|
+
#
|
27
|
+
def draw (caption_text = "LGTM")
|
28
|
+
if @img.respond_to? (:combine_options) then
|
29
|
+
@img.combine_options do |c|
|
30
|
+
c.gravity captionPosition()
|
31
|
+
c.draw "text 0,0 " << "#{caption_text}"
|
32
|
+
c.font captionFont
|
33
|
+
c.pointsize captionFontSize
|
34
|
+
c.density imageDensity
|
35
|
+
c.fill captionColor
|
36
|
+
c.resize imageMaxSize().reduce() {|w,h| w << 'x' << h} # syntax: convert -resize $wx$h
|
37
|
+
end
|
38
|
+
@img.contrast
|
39
|
+
end
|
40
|
+
yield @img if block_given?
|
41
|
+
end
|
42
|
+
|
43
|
+
def export
|
44
|
+
@img.write(@output_image_URI)
|
45
|
+
yield @output_image_URI if block_given?
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def imageMaxSize
|
52
|
+
[Configuration::OUTPUT_MAX_WIDTH.to_s, Configuration::OUTPUT_MAX_HEIGHT.to_s]
|
53
|
+
end
|
54
|
+
|
55
|
+
##
|
56
|
+
# @return [String] the position of image
|
57
|
+
# Could be either :caption_position_top or :caption_position_bottom
|
58
|
+
#
|
59
|
+
def captionPosition ()
|
60
|
+
if not [:caption_position_top, :caption_position_bottom].include? (@caption_position)
|
61
|
+
@caption_position = :caption_position_top
|
62
|
+
end
|
63
|
+
return {:caption_position_top => "north center",
|
64
|
+
:caption_position_bottom => "south center"}[@caption_position]
|
65
|
+
end
|
66
|
+
|
67
|
+
def captionFont
|
68
|
+
Configuration::ROOT_DIR << Configuration::FONT_PATH
|
69
|
+
end
|
70
|
+
|
71
|
+
def captionFontSize
|
72
|
+
Configuration::CAPTION_FONT_SIZE_DEFAULT
|
73
|
+
end
|
74
|
+
|
75
|
+
def imageDensity
|
76
|
+
Configuration::OUTPUT_DENSITY
|
77
|
+
end
|
78
|
+
|
79
|
+
##
|
80
|
+
# Decide foreground color depending on background color
|
81
|
+
# https://en.wikipedia.org/wiki/Rec._601
|
82
|
+
#
|
83
|
+
# We use this method that include magic numbers .241, .691, .068 accroding to
|
84
|
+
# the provided wikipedia link
|
85
|
+
# Math.Sqrt(
|
86
|
+
# c.R * c.R * .241 +
|
87
|
+
# c.G * c.G * .691 +
|
88
|
+
# c.B * c.B * .068)
|
89
|
+
#
|
90
|
+
# Magic cut off number is 130.
|
91
|
+
# Under 130 is too dark, so the foreground color is white
|
92
|
+
# Above is too bright so the foreground color is black
|
93
|
+
#
|
94
|
+
# @return [String] the foreground color of caption
|
95
|
+
#
|
96
|
+
def captionColor
|
97
|
+
# Copy current image data instead of working directly on working file
|
98
|
+
img = MiniMagick::Image.read(@img.to_blob)
|
99
|
+
|
100
|
+
# cutoff's x is always 0 as we only support top or bottom right now
|
101
|
+
cutoff_y = @caption_position == :caption_position_bottom ? (img.height/2).round : 0
|
102
|
+
img.crop("#{img.width}x#{img.height/2}+0+#{cutoff_y}")
|
103
|
+
|
104
|
+
# Since we are getting
|
105
|
+
img = img.resize('1x1')
|
106
|
+
rgb = img.get_pixels[0][0] # Only 1x1 pixel remember? ^_^
|
107
|
+
color = {}
|
108
|
+
['r','g','b'].zip(rgb) { |k,v| color[k] = v }
|
109
|
+
|
110
|
+
magic_color_value = color['r'] * color['r'] * 0.241
|
111
|
+
magic_color_value += color['g'] * color['g'] * 0.691
|
112
|
+
magic_color_value += color['b'] * color['b'] * 0.068
|
113
|
+
magic_color_value = Math.sqrt(magic_color_value)
|
114
|
+
|
115
|
+
return (magic_color_value.round > 130) ? "#000000" : "#FFFFFF"
|
116
|
+
end
|
117
|
+
|
118
|
+
end # End of Class
|
119
|
+
end # End of Module
|
data/lib/lgtm_hd/cli.rb
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'commander'
|
3
|
+
require 'os'
|
4
|
+
require 'lgtm_hd'
|
5
|
+
require 'net/http'
|
6
|
+
require 'tempfile'
|
7
|
+
require 'clipboard'
|
8
|
+
require 'uri'
|
9
|
+
|
10
|
+
module LgtmHD
|
11
|
+
class CLI
|
12
|
+
include Commander::Methods
|
13
|
+
|
14
|
+
def run
|
15
|
+
program :name, LgtmHD::Configuration::PROGRAM_NAME
|
16
|
+
program :version, LgtmHD::VERSION
|
17
|
+
program :description, LgtmHD::Configuration::DESCRIPTION
|
18
|
+
default_command :export
|
19
|
+
|
20
|
+
command :transform do |c|
|
21
|
+
c.syntax = 'lgtm_hd transform <source_uri> <output_uri> [options]'
|
22
|
+
c.summary = 'Generate a LGTM image from source_uri (local path or URL) into output_uri (local)'
|
23
|
+
c.description = ''
|
24
|
+
c.example '', 'lgtm_hd export http://domain.com/image.png /path/to/lgtm.png'
|
25
|
+
c.option '--clipboard', 'Copy the end result (LGTM image) to OS\'s clipboard'
|
26
|
+
|
27
|
+
c.action do |args, options|
|
28
|
+
# TODO add validation for args
|
29
|
+
uri = URI.parse(args[0])
|
30
|
+
tmp_file_name = Time.now.strftime('%Y-%m-%d_%H-%M-%S') << LgtmHD::Configuration::TEMP_FILE_PREFIX
|
31
|
+
|
32
|
+
meme_generator = MemeGenerator.new(*args)
|
33
|
+
meme_generator.draw
|
34
|
+
|
35
|
+
meme_generator.export do |output|
|
36
|
+
say "LGTM image has been generated at #{output}."
|
37
|
+
if not options.clipboard then return; end
|
38
|
+
if OS.mac? then
|
39
|
+
applescript "set the clipboard to (read (POSIX file \"#{output}\") as GIF picture)"
|
40
|
+
say "I see you are using MacOSX. Content of the file has been copied to your clipboard."
|
41
|
+
|
42
|
+
#{}`osascript -e 'set the clipboard to (read (POSIX file "#{output}") as JPEG picture)'`
|
43
|
+
# Note on 2017/05/22
|
44
|
+
# Currently Github allow pasting image directly to comment box.
|
45
|
+
# However it does not support pure text content produced by pbcopy so we have to use direct Applescript
|
46
|
+
# No Universal solution as for now.
|
47
|
+
#
|
48
|
+
# Apple Script reference: http://www.macosxautomation.com/applescript/imageevents/08.html
|
49
|
+
else
|
50
|
+
Clipboard.copy(output)
|
51
|
+
say "Path to LGTM file has been copied to your clipboard."
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
run!
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module LgtmHD
|
2
|
+
module Configuration
|
3
|
+
# Program configurations
|
4
|
+
PROGRAM_NAME = "lgtm_hd"
|
5
|
+
DESCRIPTION = "Generating images from user input with LGTM text on it, or fetching images from LGTM.in based on user's query. Finally put the image to clipboard."
|
6
|
+
|
7
|
+
TEMP_FILE_PREFIX = "lgtm_tmp_"
|
8
|
+
ROOT_DIR = ROOT_DIR
|
9
|
+
|
10
|
+
# Output Image configurations
|
11
|
+
OUTPUT_MAX_WIDTH = 500
|
12
|
+
OUTPUT_MAX_HEIGHT = 500
|
13
|
+
OUTPUT_DENSITY = 90 # or 120 point per inch
|
14
|
+
|
15
|
+
# Caption configurations
|
16
|
+
FONT_PATH = "/fonts/impact.ttf"
|
17
|
+
CAPTION_FONT_SIZE_DEFAULT = 96
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,193 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: lgtm_hd
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Huy Dinh
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-05-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.6'
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: 3.6.0
|
51
|
+
type: :development
|
52
|
+
prerelease: false
|
53
|
+
version_requirements: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - "~>"
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '3.6'
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 3.6.0
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: commander
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '4.4'
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: 4.4.3
|
71
|
+
type: :runtime
|
72
|
+
prerelease: false
|
73
|
+
version_requirements: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - "~>"
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '4.4'
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: 4.4.3
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
name: clipboard
|
83
|
+
requirement: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - "~>"
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '1.1'
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: 1.1.1
|
91
|
+
type: :runtime
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - "~>"
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '1.1'
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: 1.1.1
|
101
|
+
- !ruby/object:Gem::Dependency
|
102
|
+
name: os
|
103
|
+
requirement: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - "~>"
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '1.0'
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 1.0.0
|
111
|
+
type: :runtime
|
112
|
+
prerelease: false
|
113
|
+
version_requirements: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '1.0'
|
118
|
+
- - ">="
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: 1.0.0
|
121
|
+
- !ruby/object:Gem::Dependency
|
122
|
+
name: mini_magick
|
123
|
+
requirement: !ruby/object:Gem::Requirement
|
124
|
+
requirements:
|
125
|
+
- - "~>"
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: '4.7'
|
128
|
+
type: :runtime
|
129
|
+
prerelease: false
|
130
|
+
version_requirements: !ruby/object:Gem::Requirement
|
131
|
+
requirements:
|
132
|
+
- - "~>"
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: '4.7'
|
135
|
+
description: Generating images from user input with LGTM text on it, or fetching images
|
136
|
+
from LGTM.in based on user's query. Finally put the image to clipboard.
|
137
|
+
email:
|
138
|
+
- phradion@gmail.com
|
139
|
+
executables:
|
140
|
+
- console
|
141
|
+
- lgtm_hd
|
142
|
+
- setup
|
143
|
+
extensions: []
|
144
|
+
extra_rdoc_files: []
|
145
|
+
files:
|
146
|
+
- ".gitignore"
|
147
|
+
- ".rspec"
|
148
|
+
- ".travis.yml"
|
149
|
+
- CODE_OF_CONDUCT.md
|
150
|
+
- Gemfile
|
151
|
+
- LICENSE
|
152
|
+
- LICENSE.txt
|
153
|
+
- README.md
|
154
|
+
- Rakefile
|
155
|
+
- bin/console
|
156
|
+
- bin/lgtm_hd
|
157
|
+
- bin/setup
|
158
|
+
- fonts/impact.ttf
|
159
|
+
- images/example_1_after.gif
|
160
|
+
- images/example_1_before.gif
|
161
|
+
- images/example_2_after.jpg
|
162
|
+
- images/example_2_before.png
|
163
|
+
- lgtm_hd.gemspec
|
164
|
+
- lib/lgtm_hd.rb
|
165
|
+
- lib/lgtm_hd/cli.rb
|
166
|
+
- lib/lgtm_hd/configuration.rb
|
167
|
+
- lib/lgtm_hd/version.rb
|
168
|
+
homepage: http://github.com/phradion/lgtm_hd
|
169
|
+
licenses:
|
170
|
+
- MIT
|
171
|
+
metadata: {}
|
172
|
+
post_install_message:
|
173
|
+
rdoc_options: []
|
174
|
+
require_paths:
|
175
|
+
- lib
|
176
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
181
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
182
|
+
requirements:
|
183
|
+
- - ">="
|
184
|
+
- !ruby/object:Gem::Version
|
185
|
+
version: '0'
|
186
|
+
requirements: []
|
187
|
+
rubyforge_project:
|
188
|
+
rubygems_version: 2.4.5.1
|
189
|
+
signing_key:
|
190
|
+
specification_version: 4
|
191
|
+
summary: Generating LGTM image to clipboard.
|
192
|
+
test_files: []
|
193
|
+
has_rdoc:
|