cafe_buy_duo 0.1.52 → 0.1.53
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 +4 -4
- data/lib/cafe_buy_duo.rb +19 -15
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 385bc3207c8c11406b1a4334217f61a88631a28085a923a52fa8b17adb665257
|
4
|
+
data.tar.gz: c582a195fb18bed9a08b9cb0c7e2c109292e6341bf209974d412965d6ae90b99
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d9126d46589500b7ebf21dcb59117cde07a547ffdba727d7973588f762562807f5672c9ef0c3a1053dddbce1013f77bf2b6b93c000f57fd64db5148d9c77300b
|
7
|
+
data.tar.gz: 949882637008bafc25eaa2841c22bf95f8287b038e1b7244ac6ed74d646ec17c97069aa956ce568c3570474fd2c8fd00fa8f99d449e4bf1eef7316654ea86a93
|
data/lib/cafe_buy_duo.rb
CHANGED
@@ -2435,24 +2435,28 @@ class Wordpress
|
|
2435
2435
|
|
2436
2436
|
|
2437
2437
|
def crop_image_height_under_width(path, min_crop_ratio = 0.625)
|
2438
|
-
|
2439
|
-
|
2440
|
-
|
2441
|
-
|
2442
|
-
|
2438
|
+
img = Magick::Image.read(path).first
|
2439
|
+
width = img.columns
|
2440
|
+
height = img.rows
|
2443
2441
|
|
2444
|
-
|
2445
|
-
|
2446
|
-
|
2447
|
-
|
2442
|
+
if height > width
|
2443
|
+
min_height = (width * min_crop_ratio).to_i
|
2444
|
+
new_height = rand(min_height..width)
|
2445
|
+
crop_top = ((height - new_height) / 2.0).round
|
2448
2446
|
|
2449
|
-
|
2450
|
-
cropped.write(path)
|
2447
|
+
cropped = img.crop(0, crop_top, width, new_height, true)
|
2451
2448
|
|
2452
|
-
|
2453
|
-
|
2454
|
-
|
2455
|
-
|
2449
|
+
retries = 0
|
2450
|
+
begin
|
2451
|
+
cropped.write(path)
|
2452
|
+
rescue => e
|
2453
|
+
retries += 1
|
2454
|
+
puts "이미지 저장 오류 (#{e.message}), 재시도 #{retries}/5"
|
2455
|
+
sleep(1)
|
2456
|
+
retry if retries < 5
|
2457
|
+
raise "이미지 저장 실패: #{e.message}"
|
2458
|
+
end
|
2459
|
+
end
|
2456
2460
|
end
|
2457
2461
|
|
2458
2462
|
def auto_image(keyword = nil)
|