appicon 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +43 -0
- data/Rakefile +1 -0
- data/appicon.gemspec +24 -0
- data/bin/appicon +17 -0
- data/lib/appicon/commands/install.rb +96 -0
- data/lib/appicon/commands.rb +3 -0
- data/lib/appicon/version.rb +3 -0
- data/lib/appicon.rb +5 -0
- metadata +112 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e3bc9f03e9131169566e0f84bcf37521154c5d51
|
4
|
+
data.tar.gz: b79254ba25647bd5188bdaf8197174afe58c4d7f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c7d14f8cc3a9e8dd674e2c5188d5239ceecb9637c6fa14346e592c0f18bf41f9fa0f7c3345d9fe7ab5de8376d4ec24c96ba0d0e1fdc52de79326a225c4501e32
|
7
|
+
data.tar.gz: b4e322dfdb6f42c1cfc2ec82c222782442d4cef60f63f4e1cc9cddbccb3f198a3cc8535b46a4e136dc1be51aedf8e41567d0bfedeb15644f04ead70c8f9e5837
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Erik Sundin
|
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,43 @@
|
|
1
|
+
Do you think it's annoying having to drag and drop images in your iOS app Asset Catalog
|
2
|
+
every time an icon changes? Did you get the right image on the right size?
|
3
|
+
Do you think it's a pain in the ass dealing with lots of sizes of the icon?
|
4
|
+
Do you think these things could be automated?
|
5
|
+
|
6
|
+
*Yes, they can be.*
|
7
|
+
|
8
|
+
## About
|
9
|
+
|
10
|
+
The appicon gem lets you only ever care about one icon, eg. the 1024x1024 iTunes version.
|
11
|
+
The tool will check which sizes you have set up for your app icon in your Asset Catalog,
|
12
|
+
generate all those icons for you and install them in your Asset Catalog. Done.
|
13
|
+
|
14
|
+
## Installation
|
15
|
+
|
16
|
+
```
|
17
|
+
$ gem install appicon
|
18
|
+
```
|
19
|
+
|
20
|
+
Appicon uses ImageMagick for image conversion. Download and install ImageMagick from http://www.imagemagick.org.
|
21
|
+
Not sure if you have it installed already? Check:
|
22
|
+
|
23
|
+
```
|
24
|
+
$ convert --version
|
25
|
+
```
|
26
|
+
|
27
|
+
## Usage
|
28
|
+
|
29
|
+
```
|
30
|
+
$ appicon install iTunesIcon-1024x1024.png path/to/Images.xcassets
|
31
|
+
```
|
32
|
+
|
33
|
+
## Contact
|
34
|
+
|
35
|
+
Found a bug or missing something? Let me know, or even better, file a pull request!
|
36
|
+
|
37
|
+
Erik Sundin
|
38
|
+
|
39
|
+
- erik@eriksundin.se
|
40
|
+
|
41
|
+
## License
|
42
|
+
|
43
|
+
Appicon gem is available under the MIT license. See the LICENSE file for more info.
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/appicon.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'appicon/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "appicon"
|
8
|
+
spec.version = Appicon::VERSION
|
9
|
+
spec.authors = ["Erik Sundin"]
|
10
|
+
spec.email = ["erik@eriksundin.se"]
|
11
|
+
spec.summary = %q{Convert and install iOS App icons into an XCode Asset Catalog.}
|
12
|
+
spec.homepage = "https://github.com/eriksundin/appicon"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
21
|
+
spec.add_development_dependency "rake"
|
22
|
+
spec.add_dependency "commander", "~> 4.1.2"
|
23
|
+
spec.add_dependency 'json', '~> 1.8.1'
|
24
|
+
end
|
data/bin/appicon
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'commander/import'
|
4
|
+
|
5
|
+
$:.push File.expand_path("../../lib", __FILE__)
|
6
|
+
require 'appicon'
|
7
|
+
|
8
|
+
program :version, Appicon::VERSION
|
9
|
+
program :description, 'Generate iOS App icons from a high resolution source.'
|
10
|
+
|
11
|
+
program :help, 'Author', 'Erik Sundin <erik@eriksundin.se>'
|
12
|
+
program :help, 'Website', 'http://github.com/eriksundin'
|
13
|
+
program :help_formatter, :compact
|
14
|
+
|
15
|
+
default_command :help
|
16
|
+
|
17
|
+
require 'appicon/commands'
|
@@ -0,0 +1,96 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
command :'install' do |c|
|
4
|
+
c.syntax = "appicon install [icon] [asset catalog]"
|
5
|
+
c.summary = "Generate and install icons into an Xcode Asset Catalog."
|
6
|
+
c.description = "Every specified format in you App Icon set will be generated and installed."
|
7
|
+
|
8
|
+
c.action do |args, options|
|
9
|
+
|
10
|
+
validate_image_magick!
|
11
|
+
|
12
|
+
determine_icon! unless @icon = args[0]
|
13
|
+
determine_asset_catalog! unless @asset_catalog = args[1]
|
14
|
+
|
15
|
+
validate_icon!
|
16
|
+
validate_asset_catalog!
|
17
|
+
|
18
|
+
icon_sets = Dir.glob(File.join(@asset_catalog, '*.appiconset'))
|
19
|
+
abort("Could not find any Icon sets (.appiconset folders) in the asset catalog. Create one first!") unless icon_sets.size > 0
|
20
|
+
if icon_sets.size > 1
|
21
|
+
@icon_set = determine_icon_set! icon_sets
|
22
|
+
else
|
23
|
+
@icon_set = icon_sets.first
|
24
|
+
end
|
25
|
+
|
26
|
+
@contents_file = File.join(@icon_set, 'Contents.json')
|
27
|
+
contents = JSON.parse(File.read(@contents_file))
|
28
|
+
contents['images'].each do |image|
|
29
|
+
image_size = image['size']
|
30
|
+
image_scale = image['scale']
|
31
|
+
|
32
|
+
scaled_image_side = image_size.split('x').first.to_i * image_scale.sub('x', '').to_i
|
33
|
+
scaled_image_name = "Icon-#{image_size}-@#{image_scale}#{File.extname(@icon)}"
|
34
|
+
scaled_image_output = File.join(@icon_set, scaled_image_name)
|
35
|
+
|
36
|
+
# Generate each icon
|
37
|
+
puts "Generating #{image_size} @ #{image_scale}."
|
38
|
+
if system("convert #{@icon} -resize #{scaled_image_side}x#{scaled_image_side} #{scaled_image_output}")
|
39
|
+
|
40
|
+
# Remove old icons that are not used any more
|
41
|
+
previous_icon = image['filename']
|
42
|
+
if previous_icon
|
43
|
+
previous_icon_file = File.join(@icon_set, previous_icon)
|
44
|
+
if File.exist?(previous_icon_file) and !scaled_image_name.eql?(previous_icon)
|
45
|
+
FileUtils.rm(previous_icon_file)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
image['filename'] = scaled_image_name
|
50
|
+
|
51
|
+
else
|
52
|
+
say_error 'Failed during the conversion process for some reason...' and abort
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# Output the new JSON contents
|
57
|
+
File.open(@contents_file,"w") do |f|
|
58
|
+
f.write(JSON.pretty_generate(contents))
|
59
|
+
end
|
60
|
+
|
61
|
+
say_ok 'Done. Happy Days!'
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
private
|
66
|
+
|
67
|
+
def validate_image_magick!
|
68
|
+
abort('You need to install Image Magick! Check http://www.imagemagick.org for instructions.') unless system("which convert > /dev/null 2>&1")
|
69
|
+
end
|
70
|
+
|
71
|
+
def validate_icon!
|
72
|
+
@icon = File.expand_path(@icon)
|
73
|
+
abort("Ops! Can't find the source icon you specified. #{@icon}") unless File.exist?(@icon)
|
74
|
+
end
|
75
|
+
|
76
|
+
def validate_asset_catalog!
|
77
|
+
@asset_catalog = File.expand_path(@asset_catalog)
|
78
|
+
abort("Ops! Can't find the asset catalog you specified. #{@asset_catalog}") unless File.exist?(@asset_catalog)
|
79
|
+
abort("Ops! It does not seem you specified a valid asset catalog. It needs to be the .xcassets directory.") \
|
80
|
+
unless File.directory?(@asset_catalog) and File.extname(@asset_catalog).eql?('.xcassets')
|
81
|
+
end
|
82
|
+
|
83
|
+
def determine_icon!
|
84
|
+
@icon ||= ask "Source Icon:"
|
85
|
+
end
|
86
|
+
|
87
|
+
def determine_asset_catalog!
|
88
|
+
@asset_catalog ||= ask "Asset Catalog:"
|
89
|
+
end
|
90
|
+
|
91
|
+
def determine_icon_set! icon_sets
|
92
|
+
@icon_set ||= choose "Select Icon Set:", *icon_sets
|
93
|
+
end
|
94
|
+
|
95
|
+
|
96
|
+
end
|
data/lib/appicon.rb
ADDED
metadata
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: appicon
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Erik Sundin
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-11-21 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.5'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.5'
|
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: commander
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 4.1.2
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 4.1.2
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: json
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.8.1
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 1.8.1
|
69
|
+
description:
|
70
|
+
email:
|
71
|
+
- erik@eriksundin.se
|
72
|
+
executables:
|
73
|
+
- appicon
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- ".gitignore"
|
78
|
+
- Gemfile
|
79
|
+
- LICENSE.txt
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- appicon.gemspec
|
83
|
+
- bin/appicon
|
84
|
+
- lib/appicon.rb
|
85
|
+
- lib/appicon/commands.rb
|
86
|
+
- lib/appicon/commands/install.rb
|
87
|
+
- lib/appicon/version.rb
|
88
|
+
homepage: https://github.com/eriksundin/appicon
|
89
|
+
licenses:
|
90
|
+
- MIT
|
91
|
+
metadata: {}
|
92
|
+
post_install_message:
|
93
|
+
rdoc_options: []
|
94
|
+
require_paths:
|
95
|
+
- lib
|
96
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
requirements: []
|
107
|
+
rubyforge_project:
|
108
|
+
rubygems_version: 2.4.1
|
109
|
+
signing_key:
|
110
|
+
specification_version: 4
|
111
|
+
summary: Convert and install iOS App icons into an XCode Asset Catalog.
|
112
|
+
test_files: []
|