touchy 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in touchy.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Masami Yonehara
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # Touchy
2
+
3
+ Command line tool to find and modify illigal images
4
+
5
+ [日本語ガイド](./README_JP.md)
6
+
7
+ ## Installation
8
+
9
+ 1. install ruby(>= 1.8.7)
10
+ 2. execute the following command
11
+
12
+ ```bash
13
+ $ gem install touchy
14
+ ```
15
+
16
+ ## Usage
17
+
18
+ ### Find the images that has odd size
19
+
20
+ ```bash
21
+ $ touchy odd ./hoge/*.png
22
+ ```
23
+
24
+ ### Find the odd size images and extend this size to even one, and fill the space with transparent pixel.
25
+
26
+ ```bash
27
+ $ touchy odd ./hoge/*.png
28
+ ```
29
+
30
+ ## Contributing
31
+
32
+ 1. Fork it ( http://github.com/<my-github-username>/touchy/fork )
33
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
34
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
35
+ 4. Push to the branch (`git push origin my-new-feature`)
36
+ 5. Create new Pull Request
data/README_JP.md ADDED
@@ -0,0 +1,34 @@
1
+ # Touchy
2
+
3
+ 奇数サイズ等の画像を探し出すためのコマンドラインツールです。
4
+
5
+ ## インストール
6
+
7
+ 1. Ruby 1.8.7以上をインストールして下さい。
8
+ 2. コンソールで以下のコマンドを実行して下さい。
9
+
10
+ ```bash
11
+ $ gem install touchy
12
+ ```
13
+
14
+ ## 使い方
15
+
16
+ ### 奇数サイズの画像を探し出す
17
+
18
+ ```bash
19
+ touchy odd 画像のパス
20
+ ```
21
+
22
+ #### 例
23
+
24
+ ./hogeディレクトリ直下のpngファイルの中から探す。
25
+
26
+ ```bash
27
+ touchy odd ./hoge/*.png
28
+ ```
29
+
30
+ ### 奇数サイズの画像を探し出し、偶数サイズに修正した上で、生じた隙間を透明なピクセルで埋める
31
+
32
+ ```bash
33
+ touchy fix 画像のパス
34
+ ```
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/touchy ADDED
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env ruby
2
+ require 'pathname'
3
+ $:.unshift Pathname.new(__FILE__).realpath.join('../../lib') if $0 == __FILE__
4
+ require 'thor'
5
+ require "touchy"
6
+
7
+ module touchy
8
+ class Command < Thor
9
+ desc "odd", "search odd size images"
10
+ def odd(*path)
11
+ found = touchy.find_odd_size_images(path)
12
+
13
+ found.each do |path|
14
+ puts path
15
+ end
16
+ puts found.length.to_s + " files are found!"
17
+ end
18
+
19
+ desc "fix", "fix image's size to even"
20
+ def fix(*path)
21
+ found = touchy.find_odd_size_images(path)
22
+
23
+ found.each do |path|
24
+ image = Magick::Image.read(path).first
25
+ new_image = touchy.extend_size_to_odd image
26
+ new_image.write(path)
27
+ end
28
+ end
29
+
30
+ desc "create_test_image", "create test image"
31
+ def create_test_image(x, y, name)
32
+ image = touchy.create_transparent_image x.to_i, y.to_i
33
+ image.write(name)
34
+ end
35
+ end
36
+ end
37
+
38
+ touchy::Command.start
@@ -0,0 +1,3 @@
1
+ module Touchy
2
+ VERSION = "0.0.6"
3
+ end
data/lib/touchy.rb ADDED
@@ -0,0 +1,30 @@
1
+ require "touchy/version"
2
+ require "fastimage"
3
+ require "rmagick"
4
+ include Magick
5
+
6
+ module touchy
7
+ def self.find_odd_size_images(image_paths)
8
+ image_paths.map do |image_path|
9
+ size = FastImage.size(image_path)
10
+ image_path if !size.nil? && (size[0].odd? || size[1].odd?)
11
+ end.reject(&:nil?)
12
+ end
13
+
14
+ def self.create_transparent_image(x, y)
15
+ Image.new(x, y) do |canvas|
16
+ canvas.background_color= "Transparent"
17
+ end
18
+ end
19
+
20
+ def self.extend_size_to_odd(image)
21
+ x = image.columns
22
+ y = image.rows
23
+
24
+ x += 1 if x % 2 != 0
25
+ y += 1 if y % 2 != 0
26
+
27
+ base = create_transparent_image x, y
28
+ base.composite(image, 0, 0, OverCompositeOp)
29
+ end
30
+ end
data/touchy.gemspec ADDED
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'touchy/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "touchy"
8
+ spec.version = Touchy::VERSION
9
+ spec.authors = ["Masami Yonehara"]
10
+ spec.email = ["zeitdiebe@gmail.com"]
11
+ spec.summary = %q{the tool that find odd images}
12
+ spec.description = %q{the tool that find odd images}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "thor", "~> 0.19"
22
+ spec.add_dependency "fastimage"
23
+ spec.add_dependency "rmagick"
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.5"
26
+ spec.add_development_dependency "rake"
27
+ end
metadata ADDED
@@ -0,0 +1,137 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: touchy
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.6
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Masami Yonehara
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2015-02-19 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: thor
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '0.19'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '0.19'
30
+ - !ruby/object:Gem::Dependency
31
+ name: fastimage
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rmagick
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: bundler
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: '1.5'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: '1.5'
78
+ - !ruby/object:Gem::Dependency
79
+ name: rake
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ description: the tool that find odd images
95
+ email:
96
+ - zeitdiebe@gmail.com
97
+ executables:
98
+ - touchy
99
+ extensions: []
100
+ extra_rdoc_files: []
101
+ files:
102
+ - .gitignore
103
+ - Gemfile
104
+ - LICENSE.txt
105
+ - README.md
106
+ - README_JP.md
107
+ - Rakefile
108
+ - bin/touchy
109
+ - lib/touchy.rb
110
+ - lib/touchy/version.rb
111
+ - touchy.gemspec
112
+ homepage: ''
113
+ licenses:
114
+ - MIT
115
+ post_install_message:
116
+ rdoc_options: []
117
+ require_paths:
118
+ - lib
119
+ required_ruby_version: !ruby/object:Gem::Requirement
120
+ none: false
121
+ requirements:
122
+ - - ! '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ required_rubygems_version: !ruby/object:Gem::Requirement
126
+ none: false
127
+ requirements:
128
+ - - ! '>='
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ requirements: []
132
+ rubyforge_project:
133
+ rubygems_version: 1.8.23
134
+ signing_key:
135
+ specification_version: 3
136
+ summary: the tool that find odd images
137
+ test_files: []