iconcutter 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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 78b8137cbe79bf70fc355cbbb9d7496e16d853a7
4
+ data.tar.gz: e6c75fde8cf79ae3b8987ab94b520110826ac256
5
+ SHA512:
6
+ metadata.gz: df331a80de6474ef5a7017ae3f8c4a004fd6b0e98c7d0ee04800ad976a469bb3484fa685a52f7a7b6f979d97fca8dad44d48997e4dbd638442ba864badd7ac35
7
+ data.tar.gz: 192ed151697ba2d8c5a0dd963fe2131a38881ae23c7490458d4c1d822ce1d840fae534e951f02b067020e8a6873dcd8132c354ce58dd2aa74fcd3a39ce410d62
@@ -0,0 +1,34 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /test/tmp/
9
+ /test/version_tmp/
10
+ /tmp/
11
+
12
+ ## Specific to RubyMotion:
13
+ .dat*
14
+ .repl_history
15
+ build/
16
+
17
+ ## Documentation cache and generated files:
18
+ /.yardoc/
19
+ /_yardoc/
20
+ /doc/
21
+ /rdoc/
22
+
23
+ ## Environment normalisation:
24
+ /.bundle/
25
+ /lib/bundler/man/
26
+
27
+ # for a library or gem, you might want to ignore these files since the code is
28
+ # intended to run in multiple environments; otherwise, check them in:
29
+ # Gemfile.lock
30
+ # .ruby-version
31
+ # .ruby-gemset
32
+
33
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
34
+ .rvmrc
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in smart_sms.gemspec
4
+ gemspec
@@ -0,0 +1,42 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ iconcutter (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ coderay (1.1.0)
10
+ diff-lcs (1.2.5)
11
+ json (1.8.1)
12
+ method_source (0.8.2)
13
+ pry (0.10.1)
14
+ coderay (~> 1.1.0)
15
+ method_source (~> 0.8.1)
16
+ slop (~> 3.4)
17
+ rake (10.4.2)
18
+ rdoc (4.2.0)
19
+ json (~> 1.4)
20
+ rspec (2.14.1)
21
+ rspec-core (~> 2.14.0)
22
+ rspec-expectations (~> 2.14.0)
23
+ rspec-mocks (~> 2.14.0)
24
+ rspec-core (2.14.7)
25
+ rspec-expectations (2.14.3)
26
+ diff-lcs (>= 1.1.3, < 2.0)
27
+ rspec-mocks (2.14.4)
28
+ sdoc (0.4.1)
29
+ json (~> 1.7, >= 1.7.7)
30
+ rdoc (~> 4.0)
31
+ slop (3.6.0)
32
+
33
+ PLATFORMS
34
+ ruby
35
+
36
+ DEPENDENCIES
37
+ bundler (>= 1.0.0)
38
+ iconcutter!
39
+ pry
40
+ rake
41
+ rspec
42
+ sdoc
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 Felix Liu
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.
22
+
@@ -0,0 +1,50 @@
1
+ IconCutter
2
+ ==========
3
+
4
+ Painless way to resize your icon for all platforms: wechat, weibo, ios, android, and so on
5
+
6
+ ## Installation
7
+
8
+ 1. If you have ruby env installed on your computer, just run below command:
9
+
10
+ ```bash
11
+ gem install iconcutter
12
+ ```
13
+
14
+ 2. Or, you can directly clone this repo, see below:
15
+
16
+ ``` bash
17
+ git clone https://github.com:lyfeyaj/iconcutter.git
18
+ ```
19
+
20
+ ## Usage
21
+
22
+ Run command as below:
23
+
24
+ ``` bash
25
+ ## Options
26
+ # Usage: crop_image_as_app_icons [options] image_file
27
+ # -p, --platform x,y,z Specify app plaform: android,ios,wechat,weibo,ios_submition,all
28
+ # -o, --out [DIR] output icons directory
29
+ # -h, --help Show help message
30
+
31
+ iconcutter your_path_to_the_image -o ~/YourIconDirectory
32
+ ```
33
+
34
+ Enjoy, versions of icons for all kinds of platforms will be generated!
35
+
36
+ ## Contribute
37
+
38
+ + Fork
39
+ + Create a new branch (git checkout -b my-new-feature)
40
+ + Commit your patch or feature (git commit -am 'Added some feature')
41
+ + Push your codes (git push origin my-new-feature)
42
+ + Create a new push request
43
+
44
+ ## LICENCE
45
+
46
+ [MIT](https://github.com/lyfeyaj/iconcutter/blob/master/LICENSE)
47
+
48
+ ## Author
49
+
50
+ [Felix Liu](https://github.com/lyfeyaj)
@@ -0,0 +1,11 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require 'rspec/core'
5
+ require 'rspec/core/rake_task'
6
+
7
+ RSpec::Core::RakeTask.new(:spec) do |spec|
8
+ spec.pattern = FileList['spec/**/*_spec.rb']
9
+ end
10
+
11
+ task default: 'spec:all'
@@ -0,0 +1,5 @@
1
+ #! /usr/bin/env ruby
2
+
3
+ require File.expand_path(File.join(File.dirname(__FILE__), '../lib/iconcutter/cli'))
4
+
5
+ IconCutter::Cli.run ARGV
@@ -0,0 +1,28 @@
1
+ # encoding: utf-8
2
+
3
+ lib = File.expand_path('../lib', __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'iconcutter/version'
6
+
7
+ Gem::Specification.new do |s|
8
+ s.name = 'iconcutter'
9
+ s.version = IconCutter::VERSION
10
+ s.authors = ['lyfeyaj']
11
+ s.email = ['lyfeyaj@gmail.com']
12
+ s.description = %q{A icon cut iconcutter verification tool}
13
+ s.summary = %q{A icon cutter for all platforms, easy to customize and config}
14
+ s.homepage = 'https://github.com/lyfeyaj/iconcutter'
15
+ s.license = 'MIT'
16
+
17
+ s.files = `git ls-files`.split($/)
18
+ s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
20
+ s.require_paths = ['lib']
21
+ s.executables = ["iconcutter"]
22
+
23
+ s.add_development_dependency 'bundler', ['>= 1.0.0']
24
+ s.add_development_dependency 'rake', ['>= 0']
25
+ s.add_development_dependency 'rspec', ['>= 0']
26
+ s.add_development_dependency 'pry', ['>= 0']
27
+ s.add_development_dependency 'sdoc', ['>= 0']
28
+ end
@@ -0,0 +1,6 @@
1
+ module IconCutter
2
+ end
3
+
4
+ require 'iconcutter/version'
5
+ require 'iconcutter/versions'
6
+ require 'iconcutter/cutter'
@@ -0,0 +1,37 @@
1
+ require 'optparse'
2
+ require 'iconcutter'
3
+
4
+ module IconCutter
5
+ class Cli
6
+ def self.run(args)
7
+ options = {}
8
+
9
+ OptionParser.new do |opts|
10
+ platforms = IconCutter::Versions::PLATFORMS
11
+
12
+ opts.banner = <<-USAGE
13
+ Usage: iconcutter [options] your_image_file_path
14
+ USAGE
15
+ opts.on('-p', '--platform x,y,z', Array, "Specify app plaform: #{platforms.join(',')}") do |v|
16
+ new_v = v.map(&:downcase)
17
+ if !((platforms | v) - platforms).empty?
18
+ puts "'#{v.join(',')}' is not a vaild platform, only `#{PLATFORMS.join(',')}` can be specified"
19
+ exit
20
+ end
21
+ options[:platform] = new_v
22
+ end
23
+
24
+ opts.on('-o', '--out [DIR]', String, 'output icons directory') do |v|
25
+ options[:out] = v
26
+ end
27
+
28
+ opts.on_tail('-h', '--help', 'Show this message') do
29
+ puts opts
30
+ exit
31
+ end
32
+ end.parse!(args)
33
+
34
+ IconCutter::Cutter.process(args[0], options)
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,87 @@
1
+ module IconCutter
2
+ class Cutter
3
+ class << self
4
+ attr_accessor :image_file, :options
5
+
6
+ # Process image as icons
7
+ def process(filepath, args)
8
+ @image_file = filepath
9
+ @options = args
10
+ check_if_imagemagick_exist?
11
+ check_file_exist?
12
+ parse_options
13
+ crop_image_for @options[:platform]
14
+ end
15
+
16
+ private
17
+
18
+ # Check `imagemagick exists`
19
+ def check_if_imagemagick_exist?
20
+ if !system('which convert')
21
+ puts 'Image Magick is not installed on your system'
22
+ exit
23
+ end
24
+ end
25
+
26
+ # Check if source file's existance
27
+ def check_file_exist?
28
+ if @image_file.nil? || @image_file.empty?
29
+ puts 'No image specified! You can use `--help` option to see the usage'
30
+ exit
31
+ end
32
+ if !File.exist?(@image_file)
33
+ puts "#{@image_file} is not exists"
34
+ exit
35
+ else
36
+ @image_file = File.expand_path @image_file
37
+ end
38
+ end
39
+
40
+ # Parse Options
41
+ def parse_options
42
+ @options[:out] ||= './IconCutterResult'
43
+ @options[:out] = File.expand_path @options[:out]
44
+ if !@options[:platform]
45
+ @options[:platform] = ['all']
46
+ end
47
+ options[:platform] = IconCutter::Versions::PLATFORMS if options[:platform].include? 'all'
48
+ if !Dir.exist?(@options[:out])
49
+ puts "Output directory is not exists, creating one....#{@options[:out]}"
50
+ system "mkdir -p #{@options[:out]}"
51
+ end
52
+ (@options[:platform] - ['all']).each do |dir|
53
+ new_dir = File.join @options[:out], dir
54
+ if !Dir.exist?(new_dir)
55
+ system "mkdir -p #{new_dir}"
56
+ puts "Creating sub-categories: #{dir}"
57
+ end
58
+ end
59
+ end
60
+
61
+ # Crop (Resize) image to specified platforms
62
+ def crop_image_for(platforms)
63
+ if platforms.include? 'all'
64
+ crop_image_for(IconCutter::Versions::PLATFORMS - ['all'])
65
+ else
66
+ platforms.each do |p|
67
+ p = p.upcase
68
+ const_get("IconCutter::Versions::#{p}_VERSIONS").each do |version|
69
+ v = version.join('x')
70
+ output = output_file_by_version(v, p)
71
+ print ">> Resizing #{p} version: #{v}".ljust(40)
72
+ system "convert '#{image_file}' -resize #{v} '#{output}'"
73
+ puts ' ... Done!'
74
+ end
75
+ end
76
+ end
77
+ end
78
+
79
+ # Output files according to platform and version
80
+ def output_file_by_version(version, platform)
81
+ basename = File.basename(@image_file, '.*')
82
+ extname = File.extname @image_file
83
+ File.join @options[:out], platform.downcase, "#{basename}_#{version}#{extname}"
84
+ end
85
+ end
86
+ end
87
+ end
@@ -0,0 +1,3 @@
1
+ module IconCutter
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,31 @@
1
+ module IconCutter
2
+ module Versions
3
+ PLATFORMS = %w(android ios wechat weibo ios_submition all)
4
+
5
+ ANDROID_VERSIONS = []
6
+
7
+ IOS_VERSIONS = [
8
+ [29, 29],
9
+ [58, 58],
10
+ [80, 80],
11
+ [87, 87],
12
+ [120, 120],
13
+ [180, 180]
14
+ ]
15
+
16
+ WECHAT_VERSIONS = [
17
+ [28, 28],
18
+ [108, 108]
19
+ ]
20
+
21
+ WEIBO_VERSIONS = [
22
+ [16, 16],
23
+ [80, 80],
24
+ [120, 120]
25
+ ]
26
+
27
+ IOS_SUBMITION_VERSIONS = [
28
+ [1024, 1024]
29
+ ]
30
+ end
31
+ end
File without changes
metadata ADDED
@@ -0,0 +1,130 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: iconcutter
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - lyfeyaj
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-12-23 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.0.0
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 1.0.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '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: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: sdoc
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: A icon cut iconcutter verification tool
84
+ email:
85
+ - lyfeyaj@gmail.com
86
+ executables:
87
+ - iconcutter
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - ".gitignore"
92
+ - Gemfile
93
+ - Gemfile.lock
94
+ - LICENSE
95
+ - README.md
96
+ - Rakefile
97
+ - bin/iconcutter
98
+ - iconcutter.gemspec
99
+ - lib/iconcutter.rb
100
+ - lib/iconcutter/cli.rb
101
+ - lib/iconcutter/cutter.rb
102
+ - lib/iconcutter/version.rb
103
+ - lib/iconcutter/versions.rb
104
+ - spec/.gitkeep
105
+ homepage: https://github.com/lyfeyaj/iconcutter
106
+ licenses:
107
+ - MIT
108
+ metadata: {}
109
+ post_install_message:
110
+ rdoc_options: []
111
+ require_paths:
112
+ - lib
113
+ required_ruby_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ required_rubygems_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ requirements: []
124
+ rubyforge_project:
125
+ rubygems_version: 2.4.3
126
+ signing_key:
127
+ specification_version: 4
128
+ summary: A icon cutter for all platforms, easy to customize and config
129
+ test_files:
130
+ - spec/.gitkeep