yamg 0.3.1 → 0.3.3
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 +4 -4
- data/README.md +63 -20
- data/lib/yamg/cli.rb +7 -12
- data/lib/yamg/icon.rb +41 -26
- data/lib/yamg/splash.rb +13 -3
- data/lib/yamg/templates.yaml +2 -0
- data/lib/yamg/version.rb +1 -1
- data/lib/yamg/yamg.yml +12 -0
- data/lib/yamg.rb +2 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bf2b7296e3006b737d2a5f5780b534c13eab885a
|
4
|
+
data.tar.gz: 7b6ea2ab7b6a39df88a2785fa49fc8351bea4fc3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dfdeb113584059c2eeaad5c1c3cb188d0522106d3d34277f69cb79c018c3d9277a6274d6581dab266b040bf26ebcb16592c208ac05e45a0770eb646a3675c87f
|
7
|
+
data.tar.gz: 2c9032970481ce85899328fdfe3dd2e75084031ec07b8c274f13d93d1f84a09ab91b235f59785fedc9f933674be329269dbf4bef5cbd7da9ad171d111b05dd91
|
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# YAMG
|
2
2
|
|
3
|
-
|
3
|
+
┏ ┓
|
4
4
|
|
5
|
-
|
5
|
+
_____ _____ _____ ______ _______ _____
|
6
6
|
|\ \ / /| ___|\ \ | \/ \ ___|\ \
|
7
7
|
| \ \ / / | / /\ \ / /\ \ / /\ \
|
8
8
|
| \____\/ / /| | | | / /\ / /\ || | |____|
|
@@ -10,11 +10,11 @@
|
|
10
10
|
\|___/ / / | .--. || | \|_|/ / / || | | |
|
11
11
|
/ / / | | | || | | | || | |_, |
|
12
12
|
/____/ / |____| |____||\____\ |____| /|\ ___\___/ /|
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
| | / | | | || | | | | / | | /____ / |
|
14
|
+
|____|/ |____| |____| \|____| |____|/ \|___| | /
|
15
|
+
|____|/
|
16
16
|
|
17
|
-
|
17
|
+
┗ ┛
|
18
18
|
|
19
19
|
|
20
20
|
[](http://badge.fury.io/rb/yamg)
|
@@ -51,18 +51,45 @@ OSX
|
|
51
51
|
|
52
52
|
## Use
|
53
53
|
|
54
|
-
|
54
|
+
First time
|
55
|
+
|
56
|
+
yamg init
|
55
57
|
|
56
58
|
A `.yamg.yml` will be created on the folder.
|
59
|
+
From now on to recompile everything when needed:
|
60
|
+
|
61
|
+
yamg
|
62
|
+
|
63
|
+
An example folder `/art` of a project:
|
64
|
+
|
65
|
+
|
66
|
+
```
|
67
|
+
art
|
68
|
+
├── icons
|
69
|
+
│ ├── icon16.png
|
70
|
+
│ ├── icon32.png
|
71
|
+
│ └── icon512.svg
|
72
|
+
├── media
|
73
|
+
│ └── logo.svg
|
74
|
+
└─── splash
|
75
|
+
├── center.png
|
76
|
+
├── north.png
|
77
|
+
└── southeast.png
|
78
|
+
|
79
|
+
```
|
57
80
|
|
81
|
+
From the `.yamg.yml` you may configure differents source paths.
|
82
|
+
Also configure every export location you need (check #Support)
|
58
83
|
|
59
|
-
|
84
|
+
## Icons
|
60
85
|
|
61
86
|
Your main icon(s) may be SVG or PNG. Or both:
|
62
|
-
SVG is always the best choice
|
63
|
-
|
87
|
+
SVG is always the best choice, it will be rasterized and not resized.
|
88
|
+
Except will be with really small (16x16, 32x32, 64x64@2x) icons:
|
89
|
+
A canvas for you to bring joy to the world with your pixel art skills.
|
64
90
|
|
65
|
-
|
91
|
+
|
92
|
+
### PNG
|
66
93
|
|
67
94
|
Multiple sizes:
|
68
95
|
Just save your files with the size in pixels first, example:
|
@@ -70,27 +97,28 @@ In the 'icons/' folder: '16-icon.png', '32-icon.png', '512-icon.png'.
|
|
70
97
|
YAMG will choose the best size for the case, and don't touch
|
71
98
|
the icon if sizes are a match.
|
72
99
|
|
73
|
-
It's ok to (or if you) have only one icon, make it >512px.
|
100
|
+
It's ok to (or if you) have only one png icon, make it >512px.
|
74
101
|
|
75
|
-
|
102
|
+
### SVG
|
76
103
|
|
77
104
|
You may still use best size match: Just have you folder:
|
78
|
-
'16-icon.svg', '256-icon.svg', problably not
|
105
|
+
'16-icon.svg', '256-icon.svg', and problably not many other sizes:
|
79
106
|
The SVG will be rasterized in the correct size needed.
|
80
107
|
|
81
108
|
|
82
|
-
|
109
|
+
## Splash
|
83
110
|
|
84
111
|
Up to 9 images may be placed in a splash.
|
112
|
+
It's not patch 9, think gravity: images will be pulled towards.
|
85
113
|
Note: The center splash image must be named 'center'.
|
86
114
|
|
87
|
-
|
115
|
+
### Gravity
|
88
116
|
|
89
117
|
Just save you files with the names: 'north', 'northeast', 'south'...
|
90
118
|
Gravity will put em in the correct place, with a lil padding.
|
91
119
|
|
92
120
|
|
93
|
-
|
121
|
+
## Media
|
94
122
|
|
95
123
|
Addional media.
|
96
124
|
There's also media generator for app stores.
|
@@ -107,8 +135,23 @@ Custom screenshots:
|
|
107
135
|
scroll: 100 # Optional
|
108
136
|
|
109
137
|
|
138
|
+
## Config file
|
139
|
+
|
140
|
+
Explain yamg.yml:
|
141
|
+
|
142
|
+
```
|
143
|
+
icon:
|
144
|
+
path:
|
145
|
+
round:
|
146
|
+
```
|
110
147
|
|
111
|
-
|
148
|
+
Custom location:
|
149
|
+
|
150
|
+
some-project:
|
151
|
+
icon: [32, 64, 128]
|
152
|
+
|
153
|
+
|
154
|
+
## Support
|
112
155
|
|
113
156
|
* iOS Project
|
114
157
|
* OSX Project
|
@@ -126,12 +169,12 @@ Custom screenshots:
|
|
126
169
|
|
127
170
|
## Notes
|
128
171
|
|
129
|
-
|
172
|
+
### Media
|
130
173
|
|
131
174
|
Media is a logo, icon + name.
|
132
175
|
|
133
176
|
|
134
|
-
|
177
|
+
### Phonegap or Cordova
|
135
178
|
|
136
179
|
You may generate assets for both, but the difference is:
|
137
180
|
Phonegap (`www/res`) assets are used only on Phonegap Build.
|
data/lib/yamg/cli.rb
CHANGED
@@ -54,20 +54,15 @@ module YAMG
|
|
54
54
|
YAMG.info("Splash #{size.join('x')}px #{setup['path']}#{s}", :black)
|
55
55
|
end
|
56
56
|
|
57
|
-
def compile_work(
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
#Thread.new do # 200% speed up with 8 cores
|
65
|
-
send(:"compile_#{key}", i, d, setup)
|
66
|
-
#end
|
57
|
+
def compile_work(job, opts)
|
58
|
+
task = YAMG::TEMPLATES[job] || (works[job] && works[job]['export'])
|
59
|
+
%w(icon splash media).each do |key|
|
60
|
+
next unless (work = task[key])
|
61
|
+
work.each do |asset, size|
|
62
|
+
Thread.new do # 500% speed up with 8 cores
|
63
|
+
send(:"compile_#{key}", asset, size, setup_for(opts))
|
67
64
|
end
|
68
65
|
end
|
69
|
-
else
|
70
|
-
# puts 'Custom job!'
|
71
66
|
end
|
72
67
|
end
|
73
68
|
|
data/lib/yamg/icon.rb
CHANGED
@@ -4,16 +4,25 @@ module YAMG
|
|
4
4
|
#
|
5
5
|
#
|
6
6
|
class Icon
|
7
|
-
attr_accessor :src, :size, :dpi, :rounded, :icons
|
7
|
+
attr_accessor :src, :size, :dpi, :rounded, :radius, :icons, :img
|
8
8
|
|
9
|
-
|
9
|
+
#
|
10
|
+
# Icon
|
11
|
+
#
|
12
|
+
# Icon.new(src, size, rounded).image
|
13
|
+
# Image class
|
14
|
+
# Icon.new(src, size, rounded).image('.path.ext')
|
15
|
+
# Export image
|
16
|
+
#
|
17
|
+
def initialize(src, size, rounded = false, radius = 9)
|
10
18
|
fail if src.nil? || src.empty?
|
11
19
|
@src = src
|
12
20
|
@size = size
|
13
21
|
@rounded = rounded
|
14
22
|
@icons = YAMG.load_images(src)
|
15
23
|
YAMG.puts_and_exit("No sources in '#{src}'") if icons.empty?
|
16
|
-
@
|
24
|
+
@choosen = File.join(src, find_closest_gte_icon)
|
25
|
+
@radius = radius
|
17
26
|
@dpi = 90
|
18
27
|
end
|
19
28
|
alias_method :rounded?, :rounded
|
@@ -27,18 +36,12 @@ module YAMG
|
|
27
36
|
end
|
28
37
|
end
|
29
38
|
|
30
|
-
def
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
else
|
37
|
-
img = MiniMagick::Image.open(@path)
|
38
|
-
img.resize size # "NxN"
|
39
|
-
write_out(img, out)
|
40
|
-
end
|
41
|
-
write_out(round(img), out) if rounded?
|
39
|
+
def radius
|
40
|
+
Array.new(2, size / @radius).join(',')
|
41
|
+
end
|
42
|
+
|
43
|
+
def dimensions
|
44
|
+
img.dimensions.join(',')
|
42
45
|
end
|
43
46
|
|
44
47
|
#
|
@@ -51,18 +54,14 @@ module YAMG
|
|
51
54
|
# -compose DstIn
|
52
55
|
# -composite picture_with_rounded_corners.png
|
53
56
|
# https://gist.github.com/artemave/c20e7450af866f5e7735
|
54
|
-
def round(
|
55
|
-
size = img.dimensions.join(',')
|
56
|
-
r = img.dimensions.max / r
|
57
|
-
radius = [r, r].join(',')
|
58
|
-
|
57
|
+
def round(r = 14)
|
59
58
|
mask = MiniMagick::Image.open(img.path)
|
60
59
|
mask.format 'png'
|
61
60
|
|
62
61
|
mask.combine_options do |m|
|
63
62
|
m.alpha 'transparent'
|
64
63
|
m.background 'none'
|
65
|
-
m.draw "roundrectangle 0,0,#{
|
64
|
+
m.draw "roundrectangle 0,0,#{dimensions},#{radius}"
|
66
65
|
end
|
67
66
|
|
68
67
|
overlay = ::MiniMagick::Image.open img.path
|
@@ -71,7 +70,7 @@ module YAMG
|
|
71
70
|
overlay.combine_options do |o|
|
72
71
|
o.alpha 'transparent'
|
73
72
|
o.background 'none'
|
74
|
-
o.draw "roundrectangle 0,0,#{
|
73
|
+
o.draw "roundrectangle 0,0,#{dimensions},#{radius}"
|
75
74
|
end
|
76
75
|
|
77
76
|
masked = img.composite(mask, 'png') do |i|
|
@@ -85,14 +84,30 @@ module YAMG
|
|
85
84
|
masked
|
86
85
|
end
|
87
86
|
|
87
|
+
def image(out = nil)
|
88
|
+
temp = out || "/tmp/#{@choosen.object_id}.png"
|
89
|
+
if File.extname(@choosen) =~ /svg/
|
90
|
+
pixels = dpi ? "-d #{dpi} -p #{dpi}" : nil
|
91
|
+
args = "#{pixels} -w #{size} -h #{size} -f png"
|
92
|
+
YAMG.run_rsvg(@choosen, temp, args)
|
93
|
+
@img = MiniMagick::Image.open(temp)
|
94
|
+
else
|
95
|
+
@img = MiniMagick::Image.open(@choosen)
|
96
|
+
@img.resize size # "NxN"
|
97
|
+
end
|
98
|
+
@img = round if rounded?
|
99
|
+
write_out(out)
|
100
|
+
end
|
101
|
+
|
88
102
|
#
|
89
103
|
# Writes image to disk
|
90
104
|
#
|
91
|
-
def write_out(
|
92
|
-
|
93
|
-
|
105
|
+
def write_out(path = nil)
|
106
|
+
return img unless path
|
107
|
+
FileUtils.mkdir_p File.dirname(path)
|
108
|
+
img.write(path)
|
94
109
|
rescue Errno::ENOENT
|
95
|
-
puts_and_exit("Path not found '#{
|
110
|
+
puts_and_exit("Path not found '#{path}'")
|
96
111
|
end
|
97
112
|
end
|
98
113
|
end
|
data/lib/yamg/splash.rb
CHANGED
@@ -6,6 +6,15 @@ module YAMG
|
|
6
6
|
class Splash
|
7
7
|
attr_accessor :src, :bg, :size, :assets, :img
|
8
8
|
|
9
|
+
#
|
10
|
+
# Splash
|
11
|
+
#
|
12
|
+
# Splash.new(src, size, rounded).image
|
13
|
+
# Image class
|
14
|
+
#
|
15
|
+
# Icon.new(src, size, rounded).image('.path.ext')
|
16
|
+
# Export image
|
17
|
+
#
|
9
18
|
def initialize(src, size, background)
|
10
19
|
@src = src
|
11
20
|
@size = size
|
@@ -26,7 +35,7 @@ module YAMG
|
|
26
35
|
# Center image
|
27
36
|
#
|
28
37
|
def splash_start
|
29
|
-
icon_size = size.
|
38
|
+
icon_size = size.min / 5
|
30
39
|
img.resize icon_size if img.dimensions.max >= icon_size
|
31
40
|
img.combine_options do |o|
|
32
41
|
o.gravity 'center'
|
@@ -58,11 +67,12 @@ module YAMG
|
|
58
67
|
end
|
59
68
|
|
60
69
|
#
|
61
|
-
#
|
70
|
+
# Outputs instance or writes image to disk
|
62
71
|
#
|
63
|
-
def image(out)
|
72
|
+
def image(out = nil)
|
64
73
|
splash_start
|
65
74
|
splash_composite
|
75
|
+
return img unless out
|
66
76
|
FileUtils.mkdir_p File.dirname(out)
|
67
77
|
img.write(out)
|
68
78
|
rescue Errno::ENOENT
|
data/lib/yamg/templates.yaml
CHANGED
data/lib/yamg/version.rb
CHANGED
data/lib/yamg/yamg.yml
CHANGED
@@ -58,6 +58,18 @@ compile:
|
|
58
58
|
# Compiles to media/facebook
|
59
59
|
facebook: true
|
60
60
|
|
61
|
+
#
|
62
|
+
# Creating your own
|
63
|
+
#
|
64
|
+
# my-proj:
|
65
|
+
# path: '../app/www/img'
|
66
|
+
# # icon: './another/source' # icon here is source
|
67
|
+
# export:
|
68
|
+
# icon: # Notice: icon inside export
|
69
|
+
# 'icon16.png': 16
|
70
|
+
# 'icon64.png': 64
|
71
|
+
# 'icon128.png': 128
|
72
|
+
|
61
73
|
# Custom icons/splash
|
62
74
|
# Compiles to media/*
|
63
75
|
# custom:
|
data/lib/yamg.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yamg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marcos Piccinini
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mini_magick
|