carrierwave-vips 1.0.3 → 1.0.4

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.
Files changed (2) hide show
  1. data/lib/carrierwave/vips.rb +8 -11
  2. metadata +2 -2
@@ -174,8 +174,14 @@ module CarrierWave
174
174
  #
175
175
 
176
176
  def manipulate!
177
- cache_stored_file! if !cached?
178
- @_vimage ||= VIPS::Image.new(current_path)
177
+ cache_stored_file! unless cached?
178
+ @_vimage ||= if jpeg?
179
+ VIPS::Image.jpeg(current_path, sequential: true)
180
+ elsif png?
181
+ VIPS::Image.png(current_path, sequential: true)
182
+ else
183
+ VIPS::Image.new(current_path)
184
+ end
179
185
  @_vimage = yield @_vimage
180
186
  rescue => e
181
187
  raise CarrierWave::ProcessingError.new("Failed to manipulate file, maybe it is not a supported image? Original Error: #{e}")
@@ -210,15 +216,6 @@ module CarrierWave
210
216
  def resize_image(image, width, height, min_or_max = :min)
211
217
  ratio = get_ratio image, width, height, min_or_max
212
218
  return image if ratio == 1
213
- if jpeg? # find the shrink ratio for loading
214
- shrink_factor = [8, 4, 2, 1].find {|sf| 1.0 / ratio >= sf }
215
- shrink_factor = 1 if shrink_factor == nil
216
- image = VIPS::Image.jpeg current_path,
217
- :shrink_factor => shrink_factor, :sequential => true
218
- ratio = get_ratio image, width, height, min_or_max
219
- elsif png?
220
- image = VIPS::Image.png current_path, :sequential => true
221
- end
222
219
  if ratio > 1
223
220
  image = image.affinei_resize :nearest, ratio
224
221
  else
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: carrierwave-vips
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-10 00:00:00.000000000 Z
12
+ date: 2013-01-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ruby-vips