crop_pokemori_prof_image 0.1.0
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/.gitignore +12 -0
- data/.rspec +3 -0
- data/.travis.yml +5 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +38 -0
- data/LICENSE +21 -0
- data/README.md +105 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/crop_image/sample_face.jpg +0 -0
- data/crop_image/sample_id_number.jpg +0 -0
- data/crop_image/sample_name.jpg +0 -0
- data/crop_image/sample_whole_id_part.jpg +0 -0
- data/crop_pokemori_prof_image.gemspec +38 -0
- data/lib/crop_pokemori_prof_image.rb +29 -0
- data/lib/crop_pokemori_prof_image/create_crop_image.rb +69 -0
- data/lib/crop_pokemori_prof_image/file_operation.rb +24 -0
- data/lib/crop_pokemori_prof_image/is_pokemori_prof_image.rb +93 -0
- data/lib/crop_pokemori_prof_image/version.rb +3 -0
- data/sample.jpg +0 -0
- data/the_profile_image_files.png +0 -0
- metadata +124 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: c2d689afc178ce4a113930ab7e5d8c63110083d9
|
|
4
|
+
data.tar.gz: 247e9ff7400314a580db62a82acbc24b4ede028e
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: bdcc90f65c63933afbf6ded68182c2769da7ee459fc6f5effc56aad0262241d57196be3e9756d73f4a006c81043ad4593ca1135dff65c96a327c955381344346
|
|
7
|
+
data.tar.gz: 204382460bf73c30ea14a51244994de2a4761c46ae3a0703fc9515847cfaa5c549070199b1198ba7c872af7b3f11780da8b6808e16d48a38edd9fae5dcc5025b
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
crop_pokemori_prof_image (0.1.0)
|
|
5
|
+
rmagick
|
|
6
|
+
|
|
7
|
+
GEM
|
|
8
|
+
remote: https://rubygems.org/
|
|
9
|
+
specs:
|
|
10
|
+
diff-lcs (1.3)
|
|
11
|
+
rake (10.5.0)
|
|
12
|
+
rmagick (2.16.0)
|
|
13
|
+
rspec (3.7.0)
|
|
14
|
+
rspec-core (~> 3.7.0)
|
|
15
|
+
rspec-expectations (~> 3.7.0)
|
|
16
|
+
rspec-mocks (~> 3.7.0)
|
|
17
|
+
rspec-core (3.7.0)
|
|
18
|
+
rspec-support (~> 3.7.0)
|
|
19
|
+
rspec-expectations (3.7.0)
|
|
20
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
21
|
+
rspec-support (~> 3.7.0)
|
|
22
|
+
rspec-mocks (3.7.0)
|
|
23
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
24
|
+
rspec-support (~> 3.7.0)
|
|
25
|
+
rspec-support (3.7.0)
|
|
26
|
+
|
|
27
|
+
PLATFORMS
|
|
28
|
+
ruby
|
|
29
|
+
|
|
30
|
+
DEPENDENCIES
|
|
31
|
+
bundler (~> 1.16)
|
|
32
|
+
crop_pokemori_prof_image!
|
|
33
|
+
rake (~> 10.0)
|
|
34
|
+
rmagick
|
|
35
|
+
rspec (~> 3.0)
|
|
36
|
+
|
|
37
|
+
BUNDLED WITH
|
|
38
|
+
1.16.0
|
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017 Osamu Takiya
|
|
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,105 @@
|
|
|
1
|
+
[](https://circleci.com/gh/corselia/crop-pokemori-prof-image/tree/master)
|
|
2
|
+
|
|
3
|
+
# Overview
|
|
4
|
+
- you can crop the profile image of [`Doubutsu-No-Mori Pocket Camp` (Animal Crossing Pocket Camp)](https://ac-pocketcamp.com/)
|
|
5
|
+
- first step
|
|
6
|
+
- you prepare the profile image file(s) of `Doubutsu-No-Mori Pocket Camp` (Animal Crossing Pocket Camp)
|
|
7
|
+
- second step
|
|
8
|
+
- exec method in this gem
|
|
9
|
+
- third step
|
|
10
|
+
- you get the devided image files, be happy :)
|
|
11
|
+
|
|
12
|
+
# Installation
|
|
13
|
+
```ruby
|
|
14
|
+
$ gem install crop_pokemori_prof_image
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
# Usage
|
|
18
|
+
|
|
19
|
+
#### 1. prepare the image file(s)
|
|
20
|
+
- prepare the profile image file(s) of `Doubutsu-No-Mori Pocket Camp` (Animal Crossing Pocket Camp) like below
|
|
21
|
+
|
|
22
|
+

|
|
23
|
+
|
|
24
|
+
#### 2. require gem
|
|
25
|
+
```ruby
|
|
26
|
+
require 'crop_pokemori_prof_image'
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
#### 3. exec method
|
|
30
|
+
|
|
31
|
+
##### 3-1. `crop_single_image` method
|
|
32
|
+
- `crop_single_image` method is for only one image file
|
|
33
|
+
- `crop_single_image` method takes two arguments
|
|
34
|
+
- the first argument
|
|
35
|
+
- the image file name
|
|
36
|
+
- the second argument
|
|
37
|
+
- the output directory name
|
|
38
|
+
- optional
|
|
39
|
+
- the default value is 'crop_image'
|
|
40
|
+
|
|
41
|
+
##### 3-2. `crop_multiple_image` method
|
|
42
|
+
- `crop_multiple_image` method is for multiple image files
|
|
43
|
+
- `crop_multiple_image` method takes two arguments
|
|
44
|
+
- the first argument
|
|
45
|
+
- the directory name which contains the image files
|
|
46
|
+
- optional
|
|
47
|
+
- the default value is '.'
|
|
48
|
+
- the second argument
|
|
49
|
+
- the output directory name
|
|
50
|
+
- optional
|
|
51
|
+
- the default value is 'crop_image'
|
|
52
|
+
|
|
53
|
+
#### 4. 🎉you can get the crop image files🎉
|
|
54
|
+
- after exec method, you can get the crop image files
|
|
55
|
+
- you can get four part files per one source file
|
|
56
|
+
- 1. face
|
|
57
|
+
- naming format is `SOURCE_FILENAME_WITHOUT_EXT`_face.`EXT`
|
|
58
|
+
- 2. name
|
|
59
|
+
- naming format is `SOURCE_FILENAME_WITHOUT_EXT`_name.`EXT`
|
|
60
|
+
- 3. id number without 'ID' notation
|
|
61
|
+
- naming format is `SOURCE_FILENAME_WITHOUT_EXT`_id_number.`EXT`
|
|
62
|
+
- 4. id number with 'ID' notation
|
|
63
|
+
- naming format is `SOURCE_FILENAME_WITHOUT_EXT`_whole_id_part.`EXT`
|
|
64
|
+
|
|
65
|
+
# Example
|
|
66
|
+
|
|
67
|
+
#### when the source file is `sample.jpg`
|
|
68
|
+
- `sample.jpg` is below
|
|
69
|
+
|
|
70
|
+

|
|
71
|
+
|
|
72
|
+
#### the output four files are below
|
|
73
|
+
- note: the image with Gaussian blur for privacy
|
|
74
|
+
|
|
75
|
+
##### face (sample_face.jpg)
|
|
76
|
+

|
|
77
|
+
|
|
78
|
+
##### name (sample_name.jpg)
|
|
79
|
+

|
|
80
|
+
|
|
81
|
+
##### id number without 'ID' notation (sample_id_number.jpg)
|
|
82
|
+

|
|
83
|
+
|
|
84
|
+
##### id number with 'ID' notation (sample_whole_id_part.jpg)
|
|
85
|
+

|
|
86
|
+
|
|
87
|
+
## Development
|
|
88
|
+
|
|
89
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
90
|
+
|
|
91
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
92
|
+
|
|
93
|
+
## Contributing
|
|
94
|
+
|
|
95
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/corselia/crop-pokemori-prof-image.
|
|
96
|
+
|
|
97
|
+
## License
|
|
98
|
+
|
|
99
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
100
|
+
|
|
101
|
+
## TOO BAD! BAD! BAD!
|
|
102
|
+
- Test codes aren't written!
|
|
103
|
+
- if the source file's resolution isn't 16 vs 9, this app doesn't work correctly...
|
|
104
|
+
- for instance, iOS resolution
|
|
105
|
+
- for instance, pre-crop the image file by player
|
data/Rakefile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "crop_pokemori_prof_image"
|
|
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(__FILE__)
|
data/bin/setup
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
|
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require "crop_pokemori_prof_image/version"
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "crop_pokemori_prof_image"
|
|
8
|
+
spec.version = CropPokemoriProfImage::VERSION
|
|
9
|
+
spec.authors = ["Osamu Takiya"]
|
|
10
|
+
spec.email = ["takiya@toran.sakura.ne.jp"]
|
|
11
|
+
|
|
12
|
+
spec.summary = %q{crop the prof image of 'Doubutsu-No-Mori Pocket Camp' (Animal Crossing Pocket Camp)}
|
|
13
|
+
spec.description = %q{crop the captured profile image of 'Doubutsu-No-Mori Pocket Camp' and divide it to 'face', 'name' and 'id' images}
|
|
14
|
+
spec.homepage = "https://github.com/corselia/crop-pokemori-prof-image"
|
|
15
|
+
spec.license = "MIT"
|
|
16
|
+
|
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
|
19
|
+
# if spec.respond_to?(:metadata)
|
|
20
|
+
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
|
21
|
+
# else
|
|
22
|
+
# raise "RubyGems 2.0 or newer is required to protect against " \
|
|
23
|
+
# "public gem pushes."
|
|
24
|
+
# end
|
|
25
|
+
|
|
26
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
|
27
|
+
f.match(%r{^(test|spec|features)/})
|
|
28
|
+
end
|
|
29
|
+
spec.bindir = "exe"
|
|
30
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
31
|
+
spec.require_paths = ["lib"]
|
|
32
|
+
|
|
33
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
|
34
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
35
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
|
36
|
+
|
|
37
|
+
spec.add_dependency 'rmagick'
|
|
38
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require "crop_pokemori_prof_image/version"
|
|
2
|
+
require 'crop_pokemori_prof_image/create_crop_image'
|
|
3
|
+
require 'crop_pokemori_prof_image/is_pokemori_prof_image'
|
|
4
|
+
|
|
5
|
+
module CropPokemoriProfImage
|
|
6
|
+
extend self
|
|
7
|
+
extend CreateCropImage
|
|
8
|
+
extend IsPokemoriProfImage
|
|
9
|
+
|
|
10
|
+
def crop_single_image(image_file, output_directory='crop_image')
|
|
11
|
+
image_file = change_to_fullpath(image_file)
|
|
12
|
+
@output_directory = output_directory
|
|
13
|
+
|
|
14
|
+
crop_image_initialize(image_file)
|
|
15
|
+
create_crop_image(image_file) if pokemori_prof_image?(@normalize_image_file)
|
|
16
|
+
remove_image_file(@normalize_image_file)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def crop_multiple_image(input_directory='.', output_directory='crop_image')
|
|
20
|
+
image_files = Pathname.glob("#{change_to_fullpath(input_directory)}/*").select do |filename|
|
|
21
|
+
filename.to_s =~ /\A.*(\.jpg|\.png)\z/
|
|
22
|
+
end
|
|
23
|
+
@output_directory = output_directory
|
|
24
|
+
|
|
25
|
+
image_files.each do |image_file|
|
|
26
|
+
crop_single_image(image_file.to_s, output_directory)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
require 'crop_pokemori_prof_image/file_operation'
|
|
2
|
+
|
|
3
|
+
module CreateCropImage
|
|
4
|
+
include FileOperation
|
|
5
|
+
|
|
6
|
+
RESIZE_TO = '720x1280'
|
|
7
|
+
FACE_CROP_AREA = '130x130+295+320'
|
|
8
|
+
NAME_CROP_AREA = '125x40+300+465'
|
|
9
|
+
ID_NUMBER_CROP_AREA = '225x35+275+505'
|
|
10
|
+
WHOLE_ID_PART_CROP_AREA = '280x35+220+505'
|
|
11
|
+
|
|
12
|
+
def create_crop_image(image_file)
|
|
13
|
+
crop_face
|
|
14
|
+
crop_name
|
|
15
|
+
crop_id_number
|
|
16
|
+
crop_whole_id_part
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def crop_image_initialize(image_file) # image_file is full path
|
|
20
|
+
@image_file = image_file
|
|
21
|
+
@basename_of_image_file = basename_of_image_file(image_file)
|
|
22
|
+
@extesion_of_basename = File.extname(image_file)
|
|
23
|
+
|
|
24
|
+
make_directory_if_not_exist(@output_directory)
|
|
25
|
+
@normalize_image_file = normalize_image_file
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def normalize_image_file
|
|
29
|
+
source_image_file = change_to_fullpath("#{File.dirname(@image_file)}/#{@basename_of_image_file}#{@extesion_of_basename}")
|
|
30
|
+
normalize_image_file = change_to_fullpath("#{@output_directory}/#{@basename_of_image_file}_normalize#{@extesion_of_basename}")
|
|
31
|
+
|
|
32
|
+
command = "convert #{source_image_file} -resize #{RESIZE_TO} #{normalize_image_file}"
|
|
33
|
+
`#{command}`
|
|
34
|
+
|
|
35
|
+
normalize_image_file
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def crop_face
|
|
39
|
+
crop_face_file = change_to_fullpath("#{@output_directory}/#{@basename_of_image_file}_face#{@extesion_of_basename}")
|
|
40
|
+
command = "convert #{@normalize_image_file} -crop #{FACE_CROP_AREA} #{crop_face_file}"
|
|
41
|
+
`#{command}`
|
|
42
|
+
|
|
43
|
+
crop_face_file
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def crop_name
|
|
47
|
+
crop_name_file = change_to_fullpath("#{@output_directory}/#{@basename_of_image_file}_name#{@extesion_of_basename}")
|
|
48
|
+
command = "convert #{@normalize_image_file} -crop #{NAME_CROP_AREA} #{crop_name_file}"
|
|
49
|
+
`#{command}`
|
|
50
|
+
|
|
51
|
+
crop_name_file
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def crop_id_number
|
|
55
|
+
crop_id_number_file = change_to_fullpath("#{@output_directory}/#{@basename_of_image_file}_id_number#{@extesion_of_basename}")
|
|
56
|
+
command = "convert #{@normalize_image_file} -crop #{ID_NUMBER_CROP_AREA} #{crop_id_number_file}"
|
|
57
|
+
`#{command}`
|
|
58
|
+
|
|
59
|
+
crop_id_number_file
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def crop_whole_id_part
|
|
63
|
+
crop_whole_id_part_file = change_to_fullpath("#{@output_directory}/#{@basename_of_image_file}_whole_id_part#{@extesion_of_basename}")
|
|
64
|
+
command = "convert #{@normalize_image_file} -crop #{WHOLE_ID_PART_CROP_AREA} #{crop_whole_id_part_file}"
|
|
65
|
+
`#{command}`
|
|
66
|
+
|
|
67
|
+
crop_whole_id_part_file
|
|
68
|
+
end
|
|
69
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
require 'pathname'
|
|
2
|
+
|
|
3
|
+
module FileOperation
|
|
4
|
+
def make_directory_if_not_exist(directory)
|
|
5
|
+
directory = Pathname.new(change_to_fullpath(directory)).to_s
|
|
6
|
+
unless File.exists?(directory)
|
|
7
|
+
command = "mkdir #{directory}"
|
|
8
|
+
`#{command}`
|
|
9
|
+
end
|
|
10
|
+
directory
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def basename_of_image_file(image_file)
|
|
14
|
+
File.basename(image_file, '.*')
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def remove_image_file(filename)
|
|
18
|
+
File.delete(filename)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def change_to_fullpath(filename)
|
|
22
|
+
Pathname.new(Dir.pwd).join(filename).to_s
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
require 'rmagick'
|
|
2
|
+
|
|
3
|
+
module IsPokemoriProfImage
|
|
4
|
+
include Magick
|
|
5
|
+
|
|
6
|
+
AREA_START_X = 200
|
|
7
|
+
AREA_START_Y = 1050
|
|
8
|
+
AREA_END_X = 680
|
|
9
|
+
AREA_END_Y = 1150
|
|
10
|
+
|
|
11
|
+
RGB_COLOR = [
|
|
12
|
+
'red',
|
|
13
|
+
'green',
|
|
14
|
+
'blue',
|
|
15
|
+
].freeze
|
|
16
|
+
|
|
17
|
+
EXPECTED_PIXEL_MIN_BRIGHTNESS = {
|
|
18
|
+
red: 80 * 256,
|
|
19
|
+
green: 180 * 256,
|
|
20
|
+
blue: 160 * 256,
|
|
21
|
+
}.freeze
|
|
22
|
+
|
|
23
|
+
EXPECTED_PIXEL_MAX_BRIGHTNESS = {
|
|
24
|
+
red: 100 * 256,
|
|
25
|
+
green: 200 * 256,
|
|
26
|
+
blue: 180 * 256,
|
|
27
|
+
}.freeze
|
|
28
|
+
|
|
29
|
+
# HACK: image_file must be halfHD size
|
|
30
|
+
def pokemori_prof_image?(image_file)
|
|
31
|
+
image_object = ImageList.new(image_file)
|
|
32
|
+
|
|
33
|
+
# HACK: NOT DRY
|
|
34
|
+
result = []
|
|
35
|
+
result << image_size_invalid?(image_object)
|
|
36
|
+
result << init_pixel_brightness_valid?(image_object)
|
|
37
|
+
result << judge_area_pixel_brightness_valid?(image_object)
|
|
38
|
+
|
|
39
|
+
!(result.include?(false)) # HACK: double negative
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
private
|
|
43
|
+
def image_object(image_file)
|
|
44
|
+
ImageList.new(image_file)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def image_size_invalid?(image_object)
|
|
48
|
+
unless image_object.columns == 720 || image_object.rows == 1280 # HACK: must be half HD size
|
|
49
|
+
return false
|
|
50
|
+
end
|
|
51
|
+
true
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def pixel_brightness(image_object, x, y)
|
|
55
|
+
{
|
|
56
|
+
red: image_object.pixel_color(x, y).red,
|
|
57
|
+
green: image_object.pixel_color(x, y).green,
|
|
58
|
+
blue: image_object.pixel_color(x, y).blue,
|
|
59
|
+
}
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# if 'the color of all pixels in search area' is equal to 'the color of initial position pixel', it is true
|
|
63
|
+
def judge_area_pixel_brightness_valid?(image_object)
|
|
64
|
+
for x in AREA_START_X...AREA_END_X
|
|
65
|
+
for y in AREA_START_Y...AREA_END_Y
|
|
66
|
+
RGB_COLOR.each do |color|
|
|
67
|
+
unless pixel_brightness(image_object, x, y)[color] == init_pixel_brightness(image_object)[color]
|
|
68
|
+
return false
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
true
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# if 'the color of initial position pixel' is within the range of specified, it is true
|
|
77
|
+
def init_pixel_brightness_valid?(image_object)
|
|
78
|
+
init_pixel_brightness(image_object).each do |origin_color, brightness|
|
|
79
|
+
if brightness < EXPECTED_PIXEL_MIN_BRIGHTNESS[origin_color] || EXPECTED_PIXEL_MAX_BRIGHTNESS[origin_color] < brightness
|
|
80
|
+
return false
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
true
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def init_pixel_brightness(image_object)
|
|
87
|
+
{
|
|
88
|
+
red: image_object.pixel_color(AREA_START_X, AREA_START_Y).red,
|
|
89
|
+
green: image_object.pixel_color(AREA_START_X, AREA_START_Y).green,
|
|
90
|
+
blue: image_object.pixel_color(AREA_START_X, AREA_START_Y).blue,
|
|
91
|
+
}
|
|
92
|
+
end
|
|
93
|
+
end
|
data/sample.jpg
ADDED
|
Binary file
|
|
Binary file
|
metadata
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: crop_pokemori_prof_image
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Osamu Takiya
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2017-12-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.16'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.16'
|
|
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.0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '3.0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: rmagick
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ">="
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '0'
|
|
62
|
+
type: :runtime
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - ">="
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '0'
|
|
69
|
+
description: crop the captured profile image of 'Doubutsu-No-Mori Pocket Camp' and
|
|
70
|
+
divide it to 'face', 'name' and 'id' images
|
|
71
|
+
email:
|
|
72
|
+
- takiya@toran.sakura.ne.jp
|
|
73
|
+
executables: []
|
|
74
|
+
extensions: []
|
|
75
|
+
extra_rdoc_files: []
|
|
76
|
+
files:
|
|
77
|
+
- ".gitignore"
|
|
78
|
+
- ".rspec"
|
|
79
|
+
- ".travis.yml"
|
|
80
|
+
- Gemfile
|
|
81
|
+
- Gemfile.lock
|
|
82
|
+
- LICENSE
|
|
83
|
+
- README.md
|
|
84
|
+
- Rakefile
|
|
85
|
+
- bin/console
|
|
86
|
+
- bin/setup
|
|
87
|
+
- crop_image/sample_face.jpg
|
|
88
|
+
- crop_image/sample_id_number.jpg
|
|
89
|
+
- crop_image/sample_name.jpg
|
|
90
|
+
- crop_image/sample_whole_id_part.jpg
|
|
91
|
+
- crop_pokemori_prof_image.gemspec
|
|
92
|
+
- lib/crop_pokemori_prof_image.rb
|
|
93
|
+
- lib/crop_pokemori_prof_image/create_crop_image.rb
|
|
94
|
+
- lib/crop_pokemori_prof_image/file_operation.rb
|
|
95
|
+
- lib/crop_pokemori_prof_image/is_pokemori_prof_image.rb
|
|
96
|
+
- lib/crop_pokemori_prof_image/version.rb
|
|
97
|
+
- sample.jpg
|
|
98
|
+
- the_profile_image_files.png
|
|
99
|
+
homepage: https://github.com/corselia/crop-pokemori-prof-image
|
|
100
|
+
licenses:
|
|
101
|
+
- MIT
|
|
102
|
+
metadata: {}
|
|
103
|
+
post_install_message:
|
|
104
|
+
rdoc_options: []
|
|
105
|
+
require_paths:
|
|
106
|
+
- lib
|
|
107
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
108
|
+
requirements:
|
|
109
|
+
- - ">="
|
|
110
|
+
- !ruby/object:Gem::Version
|
|
111
|
+
version: '0'
|
|
112
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
113
|
+
requirements:
|
|
114
|
+
- - ">="
|
|
115
|
+
- !ruby/object:Gem::Version
|
|
116
|
+
version: '0'
|
|
117
|
+
requirements: []
|
|
118
|
+
rubyforge_project:
|
|
119
|
+
rubygems_version: 2.6.13
|
|
120
|
+
signing_key:
|
|
121
|
+
specification_version: 4
|
|
122
|
+
summary: crop the prof image of 'Doubutsu-No-Mori Pocket Camp' (Animal Crossing Pocket
|
|
123
|
+
Camp)
|
|
124
|
+
test_files: []
|