cafe_basics 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.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: 1d0451aa966f88b0f13e3da4eab576aa33f5963cb34e6a8bd4d4c415e4bc5104
|
4
|
+
data.tar.gz: 86ed985fe0ea99eaa3e09f4dc9993ac41f81808e840d0f8c9ece283826023bab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b08db72d293ebde33a55ac524785316cc62130f4c18b63f0c37ce8703ece4aeeb59094688b6812e46e0abb62877bc86f6d53fc6cf4cf0ea4fcb41d1b35bd6421
|
7
|
+
data.tar.gz: 2a1fd28e15ce350458c5ab6f7e9dcf688d5b9e4eb227b46b387f1d71d299b126643788a0ec7c0a39bdf46baecae4062548406ef30c0f538b84327c89d07559f9
|
data/lib/cafe_basics.rb
CHANGED
@@ -2030,24 +2030,28 @@ class Wordpress
|
|
2030
2030
|
|
2031
2031
|
|
2032
2032
|
def crop_image_height_under_width(path, min_crop_ratio = 0.625)
|
2033
|
-
|
2034
|
-
|
2035
|
-
|
2036
|
-
|
2037
|
-
|
2033
|
+
img = Magick::Image.read(path).first
|
2034
|
+
width = img.columns
|
2035
|
+
height = img.rows
|
2038
2036
|
|
2039
|
-
|
2040
|
-
|
2041
|
-
|
2042
|
-
|
2037
|
+
if height > width
|
2038
|
+
min_height = (width * min_crop_ratio).to_i
|
2039
|
+
new_height = rand(min_height..width)
|
2040
|
+
crop_top = ((height - new_height) / 2.0).round
|
2043
2041
|
|
2044
|
-
|
2045
|
-
cropped.write(path)
|
2042
|
+
cropped = img.crop(0, crop_top, width, new_height, true)
|
2046
2043
|
|
2047
|
-
|
2048
|
-
|
2049
|
-
|
2050
|
-
|
2044
|
+
retries = 0
|
2045
|
+
begin
|
2046
|
+
cropped.write(path)
|
2047
|
+
rescue => e
|
2048
|
+
retries += 1
|
2049
|
+
puts "이미지 저장 오류 (#{e.message}), 재시도 #{retries}/5"
|
2050
|
+
sleep(1)
|
2051
|
+
retry if retries < 5
|
2052
|
+
raise "이미지 저장 실패: #{e.message}"
|
2053
|
+
end
|
2054
|
+
end
|
2051
2055
|
end
|
2052
2056
|
|
2053
2057
|
def auto_image(keyword = nil)
|