balloon 1.1.1 → 1.1.2

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
  SHA256:
3
- metadata.gz: 909d8652d1b69823ed4a0a65e8802e5adf41fe37183111ad6d0f9e4035e7e882
4
- data.tar.gz: 23e566f565e83f05d92740761ad7b9d1c6b851e73e038d23d9cac833ae09f483
3
+ metadata.gz: 89bc6b2f3af3d0f77235b2ca38bc17851f0a3850a4742d14dfb462d5d32fb11d
4
+ data.tar.gz: f110eedc9a0e2ba8dde12785401755c0b4f5e264c707a4184dd35ca1a0e88aee
5
5
  SHA512:
6
- metadata.gz: 99174822071a213f398c7fcec40c40f232852dce889f095241df9a7225099040cef5834104b878a1a41398231fad1624b29e286ca5b8063f5629cec017249459
7
- data.tar.gz: 4c12e055ccc06b235e951b3edeb0f5adad4d04f58a2ff9a282827302199c1422bcb8f481884313143e9c32046e9599117e24fa6a9c4f6e6d8c92ceaf19d64b18
6
+ metadata.gz: 1228ab4477df6a100db7046cffb4436775e8f851db17009fdb18b90a645b4eeb2e7cdfc48cb6cdfaff32af44dc73f4c6ae33a4968b8cd0f583a622d715662097
7
+ data.tar.gz: 60473bbaf1ab5804eb39e23d6f2577fd475c445d82486605696e34b43026a67c5f5c7ab7cd05c04e1c646c51b9594daf28576b94d2336006bcda4c90d9477fd4
@@ -15,8 +15,8 @@ module Balloon
15
15
  processed_img = handle_original(image, ext)
16
16
  data[:original] = get_image_data(processed_img)
17
17
 
18
- resized_img = handle_resize(image, ext)
19
- data.merge!(resized_img)
18
+ total_size = handle_resize(image, ext, data)
19
+ data[:total_size] = processed_img.size.to_i + total_size.to_i
20
20
 
21
21
  mime_type = processed_img.mime_type
22
22
  extension = FileExtension.get_extension(mime_type)
@@ -45,14 +45,14 @@ module Balloon
45
45
  cache_file = File.join(cache_path, "#{file.basename}.#{ext}")
46
46
  convert << cache_file
47
47
  convert.call
48
-
48
+
49
49
  return MiniMagick::Image.open(cache_file)
50
50
  end
51
51
 
52
- def handle_resize(file, ext)
53
- return {} unless self.respond_to?(:uploader_size)
54
- return {} if store_storage.to_s == "upyun" && upyun_is_image
55
- data = {}
52
+ def handle_resize(file, ext, data)
53
+ return unless self.respond_to?(:uploader_size)
54
+ return if store_storage.to_s == "upyun" && upyun_is_image
55
+ total_size = 0
56
56
 
57
57
  uploader_size.each do |size, o|
58
58
  img = MiniMagick::Image.open(file.path)
@@ -71,13 +71,14 @@ module Balloon
71
71
 
72
72
  processed_img = MiniMagick::Image.open(cache_file)
73
73
  data[size] = get_image_data(processed_img)
74
+ total_size += processed_img.size
74
75
  end
75
76
 
76
- return data
77
+ return total_size
77
78
  end
78
79
 
79
80
  def resize(convert, image, size)
80
- width, height, symbol = size[:width], size[:height], size[:symbol]
81
+ width, height, symbol = size[:width], size[:height], size[:symbol]
81
82
 
82
83
  if !symbol.empty? || width.match(/\%/) || height.match(/\%/)
83
84
  if width == height
@@ -114,7 +115,7 @@ module Balloon
114
115
  shave_off = ((w - h) / 2).round
115
116
  convert.shave "#{shave_off}x0"
116
117
  return
117
- end
118
+ end
118
119
 
119
120
  shave_off = ((h - w) / 2).round
120
121
  convert.shave "0x#{shave_off}"
@@ -1,3 +1,3 @@
1
1
  module Balloon
2
- VERSION = "1.1.1"
2
+ VERSION = "1.1.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: balloon
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - yeeli