motion-assets 0.1.1 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 42a198c9ee75c5cb11f3ff165059ded24c3df0de
4
- data.tar.gz: 8b78ee302a50bb9649193d010d92c02aef00f471
3
+ metadata.gz: 4da73c33e57347439f70703d39a336d0db5c375d
4
+ data.tar.gz: 98022c6c15db9ec8971462854c349c291d9e1027
5
5
  SHA512:
6
- metadata.gz: a765cadb43e1d4684a7028a5b48a8a03907866452b18ecaee5db0e7c884bf739345b7559720e516e9780c46a4ddfa120615bfb0ccfb1b95579525828b4ef6775
7
- data.tar.gz: 19e8f674d082a9ddb50c6782f6d060a131ee6f0eae435879a84d402d82e5706493295da031ce896defd787b3ac5ed0a02c560bc1a524e6b68f30c4e1b5bb0e0b
6
+ metadata.gz: 4453ed39cbbddfc703be311dd682ee61a868318327d991a31d1c9bd9fa4b0acc357bd5fd1791298905b34e351b3d72de71a2731fab9cc67081901c329e4e4638
7
+ data.tar.gz: d6d161609729c1b151b52b34c094b132ae262ab7908cb40d001d2cf7f6837fff2632dc983139c22c46c950cd4bf81dc6ed7324d26d6a34af7c564ef5525486de
@@ -144,7 +144,7 @@ module Motion::Project
144
144
  parts = splash.split('|')
145
145
  path = File.join(@output_dir, parts[0])
146
146
  FileUtils.mkdir_p(File.dirname(path))
147
- generate_image(@source_splash, path, parts[1])
147
+ crop_image(@source_splash, path, parts[1])
148
148
  @images << path
149
149
  App.info "-", parts[0]
150
150
  end
@@ -155,7 +155,7 @@ module Motion::Project
155
155
  @icons.each do |icon|
156
156
  path = File.join(@output_dir, icon.name)
157
157
  FileUtils.mkdir_p(File.dirname(path))
158
- generate_image(@source_icon, path, icon.dimensions)
158
+ resize_image(@source_icon, path, icon.dimensions)
159
159
  @images << path
160
160
  App.info "-", icon.name
161
161
  end
@@ -170,13 +170,23 @@ module Motion::Project
170
170
  end
171
171
  end
172
172
 
173
- def generate_image(source, path, dimensions)
173
+ def resize_image(source, path, dimensions)
174
174
  image = MiniMagick::Image.open(source)
175
175
  image.resize(dimensions)
176
176
  image.format("png")
177
177
  image.write(path)
178
178
  end
179
179
 
180
+ def crop_image(source, path, dimensions)
181
+ image = MiniMagick::Image.open(source)
182
+ result = image.combine_options do |cmd|
183
+ cmd.gravity(:center)
184
+ cmd.crop("#{dimensions}!+0+0")
185
+ end
186
+ result.format("png")
187
+ result.write(path)
188
+ end
189
+
180
190
  def validate_source_icon
181
191
  unless File.exist?(@source_icon)
182
192
  App.fail "You have to provide a valid base icon in your rakefile : app.assets.source_icon = './some/path/image.png"
@@ -1,5 +1,5 @@
1
1
  module Motion::Project
2
2
  class Assets
3
- VERSION = '0.1.1'
3
+ VERSION = '0.1.2'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: motion-assets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joffrey Jaffeux