cafe_buy 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.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: 377206e549689ca46032b752398b86bddfdb202779e465a904faaf90045c5ab6
|
4
|
+
data.tar.gz: a59c83c0b4ab6966c9c039caa7eb5aa82834bd85a95518e9b1ee637a2418882f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b37d8f1d406ec35b5ae6dd9cf68b4d757c43f2297921c36aedafdda45a8d6fc478cc557afdfe16a970f54948162b6a6ddc0d9913609c349223ce466de2d859a1
|
7
|
+
data.tar.gz: 0a66c5866111aaad5471e8e024662a1d3d881496691a86b71c86d2589849f69f1f03d98626b13697b575a54e68294d54c914bf996cb6f7698cd8134ec3608022
|
data/lib/cafe_buy.rb
CHANGED
@@ -2367,24 +2367,28 @@ class Wordpress
|
|
2367
2367
|
|
2368
2368
|
|
2369
2369
|
def crop_image_height_under_width(path, min_crop_ratio = 0.625)
|
2370
|
-
|
2371
|
-
|
2372
|
-
|
2373
|
-
|
2374
|
-
|
2370
|
+
img = Magick::Image.read(path).first
|
2371
|
+
width = img.columns
|
2372
|
+
height = img.rows
|
2375
2373
|
|
2376
|
-
|
2377
|
-
|
2378
|
-
|
2379
|
-
|
2374
|
+
if height > width
|
2375
|
+
min_height = (width * min_crop_ratio).to_i
|
2376
|
+
new_height = rand(min_height..width)
|
2377
|
+
crop_top = ((height - new_height) / 2.0).round
|
2380
2378
|
|
2381
|
-
|
2382
|
-
cropped.write(path)
|
2379
|
+
cropped = img.crop(0, crop_top, width, new_height, true)
|
2383
2380
|
|
2384
|
-
|
2385
|
-
|
2386
|
-
|
2387
|
-
|
2381
|
+
retries = 0
|
2382
|
+
begin
|
2383
|
+
cropped.write(path)
|
2384
|
+
rescue => e
|
2385
|
+
retries += 1
|
2386
|
+
puts "이미지 저장 오류 (#{e.message}), 재시도 #{retries}/5"
|
2387
|
+
sleep(1)
|
2388
|
+
retry if retries < 5
|
2389
|
+
raise "이미지 저장 실패: #{e.message}"
|
2390
|
+
end
|
2391
|
+
end
|
2388
2392
|
end
|
2389
2393
|
|
2390
2394
|
def auto_image(keyword = nil)
|