frameit 2.3.0 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b3051f6bc614da778f504a828173c4dbf3704f99
4
- data.tar.gz: 9ce4a4ab91e660e59d1ec28df45f888923ef68db
3
+ metadata.gz: d3069491e6493347dfc626e17df9f0b06758f415
4
+ data.tar.gz: 215c7531bab266b4b8d6ebf343b282523810ff23
5
5
  SHA512:
6
- metadata.gz: e1583fcdc2ffbfd3d359d8b710325fd35f12cfb3be6132958890b88257d13433f71a24551111558bde84dd6a682ea6f6a6af71ea60c3b96c1f14a281399b3b6f
7
- data.tar.gz: 0618a55cf147c1aef93b1dadc5ab7dcd329d25f3ca87b510879ae4fce9e00345bfccc5dee47819f0772d3ff1663ac9eac313a2ed04c677fea741b3eb323ad6aa
6
+ metadata.gz: ef8c0cbb1cc42af78848877e7e78ef54b18017db5b21ffde646212d121592513d8801b444124945316c0627a288a5cce4c1d9cd3dc8b343151318cbe2335bbdc
7
+ data.tar.gz: 14a01c6c7cfea720d42bbef42eca4407cc7a4822c761a570e0b213a7d8d6f1ca7294e6b90abbe80a5fb7db8589cc847c1b2b81a567d7c01f5fe506a0d04ac536
@@ -85,7 +85,7 @@ module Frameit
85
85
  end
86
86
 
87
87
  if key == 'padding'
88
- raise "padding must be type integer" unless value.kind_of? Integer
88
+ raise "padding must be type integer or pair of integers of format 'AxB'" unless value.kind_of?(Integer) || value.split('x').length == 2
89
89
  end
90
90
  end
91
91
  end
@@ -92,24 +92,43 @@ module Frameit
92
92
  @image = put_into_frame
93
93
 
94
94
  # Decrease the size of the framed screenshot to fit into the defined padding + background
95
- frame_width = background.width - frame_padding * 2
95
+ frame_width = background.width - horizontal_frame_padding * 2
96
96
  image.resize "#{frame_width}x"
97
97
  end
98
98
 
99
- @image = put_device_into_background(background)
99
+ self.top_space_above_device = vertical_frame_padding
100
100
 
101
101
  if fetch_config['title']
102
- @image = add_title
102
+ background = put_title_into_background(background)
103
103
  end
104
104
 
105
+ @image = put_device_into_background(background)
106
+
105
107
  image
106
108
  end
107
109
 
108
- # Padding around the frames
109
- def frame_padding
110
+ # Horizontal adding around the frames
111
+ def horizontal_frame_padding
112
+ padding = fetch_config['padding']
113
+ unless padding.kind_of?(Integer)
114
+ padding = padding.split('x')[0].to_i
115
+ end
116
+ return scale_padding(padding)
117
+ end
118
+
119
+ # Vertical adding around the frames
120
+ def vertical_frame_padding
121
+ padding = fetch_config['padding']
122
+ unless padding.kind_of?(Integer)
123
+ padding = padding.split('x')[1].to_i
124
+ end
125
+ return scale_padding(padding)
126
+ end
127
+
128
+ def scale_padding(padding)
110
129
  multi = 1.0
111
130
  multi = 1.7 if self.screenshot.triple_density?
112
- return fetch_config['padding'] * multi
131
+ return padding * multi
113
132
  end
114
133
 
115
134
  # Returns a correctly sized background image
@@ -124,16 +143,6 @@ module Frameit
124
143
 
125
144
  def put_device_into_background(background)
126
145
  left_space = (background.width / 2.0 - image.width / 2.0).round
127
- bottom_space = -(image.height / 10).round # to be just a bit below the image bottom
128
- bottom_space -= 40 if screenshot.portrait? # even more for portrait mode
129
-
130
- if screenshot.mini?
131
- # Such small devices need special treatment
132
- bottom_space -= 50 if screenshot.portrait?
133
- bottom_space += 65 unless screenshot.portrait?
134
- end
135
-
136
- self.top_space_above_device = background.height - image.height - bottom_space
137
146
 
138
147
  @image = background.composite(image, "png") do |c|
139
148
  c.compose "Over"
@@ -152,9 +161,9 @@ module Frameit
152
161
  end
153
162
 
154
163
  # Add the title above the device
155
- # rubocop:disable Metrics/AbcSize
156
- def add_title
157
- title_images = build_title_images(image.width)
164
+ def put_title_into_background(background)
165
+ title_images = build_title_images(image.width, image.height)
166
+
158
167
  keyword = title_images[:keyword]
159
168
  title = title_images[:title]
160
169
 
@@ -177,12 +186,15 @@ module Frameit
177
186
  sum_width *= smaller
178
187
  end
179
188
 
180
- top_space = (top_space_above_device / 2.0 - (actual_font_size / 2.0 * smaller)).round # centered
181
- left_space = (image.width / 2.0 - sum_width / 2.0).round
189
+ vertical_padding = vertical_frame_padding
190
+ top_space = vertical_padding
191
+ left_space = (background.width / 2.0 - sum_width / 2.0).round
192
+
193
+ self.top_space_above_device += title.height + vertical_padding
182
194
 
183
195
  # First, put the keyword on top of the screenshot, if we have one
184
196
  if keyword
185
- @image = image.composite(keyword, "png") do |c|
197
+ background = background.composite(keyword, "png") do |c|
186
198
  c.compose "Over"
187
199
  c.geometry "+#{left_space}+#{top_space}"
188
200
  end
@@ -191,16 +203,15 @@ module Frameit
191
203
  end
192
204
 
193
205
  # Then, put the title on top of the screenshot next to the keyword
194
- @image = image.composite(title, "png") do |c|
206
+ background = background.composite(title, "png") do |c|
195
207
  c.compose "Over"
196
208
  c.geometry "+#{left_space}+#{top_space}"
197
209
  end
198
- image
210
+ background
199
211
  end
200
- # rubocop:enable Metrics/AbcSize
201
212
 
202
213
  def actual_font_size
203
- [top_space_above_device / 3.0, @image.width / 30.0].max.round
214
+ [@image.width / 10.0].max.round
204
215
  end
205
216
 
206
217
  # The space between the keyword and the title
@@ -209,17 +220,17 @@ module Frameit
209
220
  end
210
221
 
211
222
  # This will build 2 individual images with the title, which will then be added to the real image
212
- def build_title_images(max_width)
223
+ def build_title_images(max_width, max_height)
213
224
  words = [:keyword, :title].keep_if { |a| fetch_text(a) } # optional keyword/title
214
225
  results = {}
215
226
  words.each do |key|
216
227
  # Create empty background
217
228
  empty_path = File.join(Helper.gem_path('frameit'), "lib/assets/empty.png")
218
229
  title_image = MiniMagick::Image.open(empty_path)
219
- image_height = actual_font_size * 2 # gets trimmed afterwards anyway, and on the iPad the `y` would get cut
230
+ image_height = max_height # gets trimmed afterwards anyway, and on the iPad the `y` would get cut
220
231
  title_image.combine_options do |i|
221
- # * 2.0 as the text might be larger than the actual image. We're trimming afterwards anyway
222
- i.resize "#{max_width * 2.0}x#{image_height}!" # `!` says it should ignore the ratio
232
+ # Oversize as the text might be larger than the actual image. We're trimming afterwards anyway
233
+ i.resize "#{max_width * 5.0}x#{image_height}!" # `!` says it should ignore the ratio
223
234
  end
224
235
 
225
236
  current_font = font(key)
@@ -227,6 +238,8 @@ module Frameit
227
238
  Helper.log.debug "Using #{current_font} as font the #{key} of #{screenshot.path}" if $verbose and current_font
228
239
  Helper.log.debug "Adding text '#{text}'" if $verbose
229
240
 
241
+ text.gsub! '\n', "\n"
242
+
230
243
  # Add the actual title
231
244
  title_image.combine_options do |i|
232
245
  i.font current_font if current_font
@@ -267,10 +280,10 @@ module Frameit
267
280
  end
268
281
 
269
282
  # No string files, fallback to Framefile config
270
- result = fetch_config[type.to_s]['text']
283
+ result = fetch_config[type.to_s]['text'] if fetch_config[type.to_s]
271
284
  Helper.log.debug "Falling back to default text as there was nothing specified in the .strings file" if $verbose
272
285
 
273
- if !result and type == :title
286
+ if type == :title and !result
274
287
  # title is mandatory
275
288
  raise "Could not get title for screenshot #{screenshot.path}. Please provide one in your Framefile.json".red
276
289
  end
@@ -22,9 +22,9 @@ module Frameit
22
22
  sizes = Deliver::AppScreenshot::ScreenSize
23
23
  case @screen_size
24
24
  when sizes::IOS_55
25
- return 'iPhone_6_Plus'
25
+ return 'iPhone-6s-Plus'
26
26
  when sizes::IOS_47
27
- return 'iPhone_6'
27
+ return 'iPhone-6s'
28
28
  when sizes::IOS_40
29
29
  return 'iPhone_5s'
30
30
  when sizes::IOS_35
@@ -11,7 +11,7 @@ module Frameit
11
11
  ]
12
12
  joiner = "_"
13
13
 
14
- if screenshot.device_name.include?('iPad')
14
+ if screenshot.device_name.include?('iPad') || screenshot.device_name.include?('6s')
15
15
  parts = [
16
16
  screenshot.device_name,
17
17
  (screenshot.color == 'SpaceGray' ? "Space-Gray" : "Silver"),
@@ -1,3 +1,3 @@
1
1
  module Frameit
2
- VERSION = "2.3.0"
2
+ VERSION = "2.4.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: frameit
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Felix Krause
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-04 00:00:00.000000000 Z
11
+ date: 2015-11-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fastlane_core
@@ -243,7 +243,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
243
243
  version: '0'
244
244
  requirements: []
245
245
  rubyforge_project:
246
- rubygems_version: 2.5.0
246
+ rubygems_version: 2.4.0
247
247
  signing_key:
248
248
  specification_version: 4
249
249
  summary: Quickly put your screenshots into the right device frames