nblog_zon 111.120.002 → 111.120.003
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/nblog_zon.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: fe5bf260ce4df25706be5b4c50d08b9b31c50949b0e7ed6c17dbd6dbc566b622
|
4
|
+
data.tar.gz: 0d4b42bf5d55b0b553c6dede47877dc82b218b49c7deba4c2474cd59ab426cc1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0870375b45d3327fc7b74eb96a86ccf16f3c9d0714f1c3f0942174af02a2f3bfcd4703f5f3bedfe7b1db225bec6d26ae9e9db11de602e20f4d486b29b9316482'
|
7
|
+
data.tar.gz: 3bece6f01d16968e558695f5d457809f90f5ae6c141e7c5ba908fcc34d490027111e8aa9e259d6486e9fc36be1c5963dd03eaeb384b69efc670cff976591b1a7
|
data/lib/nblog_zon.rb
CHANGED
@@ -2241,24 +2241,28 @@ class Wordpress
|
|
2241
2241
|
end
|
2242
2242
|
|
2243
2243
|
def crop_image_height_under_width(path, min_crop_ratio = 0.625)
|
2244
|
-
|
2245
|
-
|
2246
|
-
|
2247
|
-
|
2248
|
-
|
2244
|
+
img = Magick::Image.read(path).first
|
2245
|
+
width = img.columns
|
2246
|
+
height = img.rows
|
2249
2247
|
|
2250
|
-
|
2251
|
-
|
2252
|
-
|
2253
|
-
|
2248
|
+
if height > width
|
2249
|
+
min_height = (width * min_crop_ratio).to_i
|
2250
|
+
new_height = rand(min_height..width)
|
2251
|
+
crop_top = ((height - new_height) / 2.0).round
|
2254
2252
|
|
2255
|
-
|
2256
|
-
cropped.write(path)
|
2253
|
+
cropped = img.crop(0, crop_top, width, new_height, true)
|
2257
2254
|
|
2258
|
-
|
2259
|
-
|
2260
|
-
|
2261
|
-
|
2255
|
+
retries = 0
|
2256
|
+
begin
|
2257
|
+
cropped.write(path)
|
2258
|
+
rescue => e
|
2259
|
+
retries += 1
|
2260
|
+
puts "이미지 저장 오류 (#{e.message}), 재시도 #{retries}/5"
|
2261
|
+
sleep(1)
|
2262
|
+
retry if retries < 5
|
2263
|
+
raise "이미지 저장 실패: #{e.message}"
|
2264
|
+
end
|
2265
|
+
end
|
2262
2266
|
end
|
2263
2267
|
|
2264
2268
|
def auto_image(keyword = nil)
|