obf 0.6.30 → 0.6.31

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/obf/utils.rb +11 -5
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 69c154d2e11fec6d5cb7c58b72d02cb1f5581b13
4
- data.tar.gz: aeef062d222835392d16f2681f3cd956ac941b83
3
+ metadata.gz: 8d429c4dfe662ff1048c6a2e74a13c8640e3da35
4
+ data.tar.gz: 7d3bb396e6ce6317cc24a09e1df2c3adfee5e55e
5
5
  SHA512:
6
- metadata.gz: f24cbd9fe728c3190144cb9a301a5d0923594243aa605ce7ed8c09c71cea2829594087d607523bc569df8a379798d09f6842fcd151eb6fdaa9cd1a511921557d
7
- data.tar.gz: b7a2853bbdc5940155b2d7bb68e997430591c4193788525380897cd394dd12f2ded977fc9db35c598f51cc466435bf3c992854c728b50125260ef384c50528e5
6
+ metadata.gz: 6fc702de3b29b71c0ee57cb6fbb64404e33bf10e37454f094769bf3c84835f45c93e3206aa03abb2b83a74ab243faee3ec970a0a63d16aed9abf445d8677595f
7
+ data.tar.gz: 3b15fc57800c0d5603f0e2cd1fb821d1073e5c061bb91b98949b93ab6b6ad113a9b02a46189d2f9d65131c4d63e435cc43d1ad55671a79d8fe02f630a2bf5310
data/lib/obf/utils.rb CHANGED
@@ -135,6 +135,7 @@ module OBF::Utils
135
135
  end
136
136
  type = MIME::Types[image['content_type']]
137
137
  type = type && type[0]
138
+ extension = nil
138
139
  if type.respond_to?(:preferred_extension)
139
140
  extension = type && ("." + type.preferred_extension)
140
141
  elsif type.respond_to?(:extensions)
@@ -152,11 +153,16 @@ module OBF::Utils
152
153
  return nil
153
154
  end
154
155
  file.close
155
- # TODO: maybe convert to jpg instead of png?
156
- # see https://github.com/prawnpdf/prawn/issues/324
157
- # in that case, fill the image with a white background, perhaps?
158
- `convert #{file.path} -density 1200 -resize 300x300 -background white -gravity center -extent 300x300 #{file.path}.png`
159
- "#{file.path}.png"
156
+ if extension && ['image/png', 'image/jpeg', 'image/jpg', 'image/gif'].include?(image['content_type']) && image['width'] < 1000 && image['width'] == image['height']
157
+ `cp #{file.path} #{file.path}.#{extension}`
158
+ "#{file.path}.#{extension}"
159
+ else
160
+ # TODO: maybe convert to jpg instead of png?
161
+ # see https://github.com/prawnpdf/prawn/issues/324
162
+ # in that case, fill the image with a white background, perhaps?
163
+ `convert #{file.path} -density 1200 -resize 300x300 -background white -gravity center -extent 300x300 #{file.path}.png`
164
+ "#{file.path}.png"
165
+ end
160
166
  end
161
167
 
162
168
  def self.sound_raw(url)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: obf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.30
4
+ version: 0.6.31
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Whitmer