cafe_basics_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_basics_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: 6b868b13d28d76acb532714d33421cd445eb6b369b1a369a80c3711f26fb995a
|
4
|
+
data.tar.gz: b4b5777cb76884c022ed55c6ab9c16a34b84e9a61db13923a1fd94da9ed1e50e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b60c2de99e80f65a1b9bb4b0fc231c9c7ee0fb3fb5d81d5fdb20524391a047e6003bb188924aec1614c76936e6aa8941b31d5e2609e60c7eaff1160df4b0812
|
7
|
+
data.tar.gz: 4caf5a67d2c104a676c40e5c41dedef98c3aabcd276d8f3f36fc9ecc10d9328516caebbe998725d5a3394541aca32877638c44bf73f44d443e5693e71d8d459d
|
data/lib/cafe_basics_duo.rb
CHANGED
@@ -2097,24 +2097,28 @@ class Wordpress
|
|
2097
2097
|
|
2098
2098
|
|
2099
2099
|
def crop_image_height_under_width(path, min_crop_ratio = 0.625)
|
2100
|
-
|
2101
|
-
|
2102
|
-
|
2103
|
-
|
2104
|
-
|
2100
|
+
img = Magick::Image.read(path).first
|
2101
|
+
width = img.columns
|
2102
|
+
height = img.rows
|
2105
2103
|
|
2106
|
-
|
2107
|
-
|
2108
|
-
|
2109
|
-
|
2104
|
+
if height > width
|
2105
|
+
min_height = (width * min_crop_ratio).to_i
|
2106
|
+
new_height = rand(min_height..width)
|
2107
|
+
crop_top = ((height - new_height) / 2.0).round
|
2110
2108
|
|
2111
|
-
|
2112
|
-
cropped.write(path)
|
2109
|
+
cropped = img.crop(0, crop_top, width, new_height, true)
|
2113
2110
|
|
2114
|
-
|
2115
|
-
|
2116
|
-
|
2117
|
-
|
2111
|
+
retries = 0
|
2112
|
+
begin
|
2113
|
+
cropped.write(path)
|
2114
|
+
rescue => e
|
2115
|
+
retries += 1
|
2116
|
+
puts "이미지 저장 오류 (#{e.message}), 재시도 #{retries}/5"
|
2117
|
+
sleep(1)
|
2118
|
+
retry if retries < 5
|
2119
|
+
raise "이미지 저장 실패: #{e.message}"
|
2120
|
+
end
|
2121
|
+
end
|
2118
2122
|
end
|
2119
2123
|
|
2120
2124
|
def auto_image(keyword = nil)
|