cafe_basics 0.1.37 → 0.1.50
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 +160 -52
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3ae02876f6307f3220ea2e2d9235cfd2c30bc3a3a113ea07180b597d401a8c0
|
4
|
+
data.tar.gz: b9cf2734d45e343d41d27e35fcd3c40bb2c714a397e9e8a1ddb1cafdf8b48d8d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 91f7a4429ffd6a42f7c6549bef559c8d1f0893603eecc4b3da95b72b27ee08dad75f9dade2d77b0a73ad9e29bf1a8f3337cfd4d3d0ad038db8ecdad33e8f56f3
|
7
|
+
data.tar.gz: b295a5b9e353c883ee2e2a7654faa09cf2a415268b69f12c86a5fb9ba588f72017c99720295b11066512cdc430944b08d9e224bf845d453a1b4f19e034570b4a
|
data/lib/cafe_basics.rb
CHANGED
@@ -18,6 +18,7 @@ require 'digest'
|
|
18
18
|
require 'auto_click'
|
19
19
|
require 'rainbow/refinement'
|
20
20
|
require 'httpclient'
|
21
|
+
#require 'win32ole'
|
21
22
|
include AutoClickMethods
|
22
23
|
using Rainbow
|
23
24
|
include Glimmer
|
@@ -242,8 +243,38 @@ end
|
|
242
243
|
class Naver
|
243
244
|
def initialize
|
244
245
|
@seed = 1
|
246
|
+
#kill_selenium_chrome #기존 창 모두 닫는 명령
|
247
|
+
#sleep(1)
|
245
248
|
end
|
246
249
|
|
250
|
+
#def kill_selenium_chrome #기존 창 모두 닫는 코드
|
251
|
+
# wmi = WIN32OLE.connect("winmgmts://")
|
252
|
+
# chrome_procs = wmi.ExecQuery("SELECT * FROM Win32_Process WHERE Name = 'chrome.exe'")
|
253
|
+
|
254
|
+
# chrome_procs.each do |proc|
|
255
|
+
# cmd = proc.CommandLine
|
256
|
+
# if cmd && cmd.include?("user-data-dir=C:/naver_cookie")
|
257
|
+
# puts "→ 크롬 창 초기화: PID #{proc.ProcessId}"
|
258
|
+
# begin
|
259
|
+
# proc.Terminate
|
260
|
+
# rescue
|
261
|
+
#puts "→ 이미 종료된 프로세스: #{proc.ProcessId}"
|
262
|
+
# end
|
263
|
+
# end
|
264
|
+
# end
|
265
|
+
|
266
|
+
# chromedriver도 같이 종료
|
267
|
+
# chromedrivers = wmi.ExecQuery("SELECT * FROM Win32_Process WHERE Name = 'chromedriver.exe'")
|
268
|
+
# chromedrivers.each do |proc|
|
269
|
+
# puts "→ 크롬 창 초기화: PID #{proc.ProcessId}"
|
270
|
+
# begin
|
271
|
+
# proc.Terminate
|
272
|
+
# rescue
|
273
|
+
#puts "→ 이미 종료된 chromedriver: #{proc.ProcessId}"
|
274
|
+
# end
|
275
|
+
# end
|
276
|
+
#end
|
277
|
+
|
247
278
|
|
248
279
|
def chrome_setup(user_id, proxy)
|
249
280
|
naver_cookie_dir = "C:/naver_cookie"
|
@@ -2078,52 +2109,106 @@ class Wordpress
|
|
2078
2109
|
img = Magick::Image.read('./image/memory.png').first
|
2079
2110
|
width = img.columns
|
2080
2111
|
height = img.rows
|
2081
|
-
|
2082
|
-
|
2083
|
-
|
2084
|
-
|
2085
|
-
|
2112
|
+
|
2113
|
+
# '원본'이 선택된 경우, 리사이징을 하지 않고 원본 이미지를 그대로 반환
|
2114
|
+
if w == 'original'
|
2115
|
+
return img # 원본 이미지 그대로 반환
|
2116
|
+
else
|
2117
|
+
begin
|
2118
|
+
if @data['image_type'][0].checked? or @data['image_type'][2].checked?
|
2119
|
+
# 비율을 맞추어 리사이징
|
2120
|
+
img.resize!(w, w * (height.to_f / width.to_f))
|
2121
|
+
else
|
2122
|
+
# 정사각형으로 리사이징
|
2123
|
+
img.resize!(w, w)
|
2124
|
+
end
|
2125
|
+
rescue
|
2126
|
+
img.resize!(w, w) # 예외 처리 시에도 리사이징
|
2086
2127
|
end
|
2087
|
-
rescue
|
2088
|
-
img.resize!(w, w)
|
2089
2128
|
end
|
2129
|
+
|
2130
|
+
# 리사이징된 이미지 저장
|
2090
2131
|
img.write('./image/memory.png')
|
2091
2132
|
end
|
2092
2133
|
|
2134
|
+
def wrap_text_to_fit(draw, text, max_width, max_height, font_path, initial_size)
|
2135
|
+
size = initial_size
|
2136
|
+
draw.font = font_path
|
2137
|
+
|
2138
|
+
loop do
|
2139
|
+
draw.pointsize = size
|
2140
|
+
words = text.chars # 글자 단위로 자름 (한국어 기준)
|
2141
|
+
lines = []
|
2142
|
+
line = ""
|
2143
|
+
|
2144
|
+
words.each do |char|
|
2145
|
+
test_line = line + char
|
2146
|
+
metrics = draw.get_type_metrics(test_line)
|
2147
|
+
if metrics.width > max_width
|
2148
|
+
lines << line
|
2149
|
+
line = char
|
2150
|
+
else
|
2151
|
+
line = test_line
|
2152
|
+
end
|
2153
|
+
end
|
2154
|
+
lines << line unless line.empty?
|
2155
|
+
|
2156
|
+
line_height = draw.get_type_metrics("가").height
|
2157
|
+
total_height = line_height * lines.size
|
2158
|
+
|
2159
|
+
# 세로 초과 안 하면 성공
|
2160
|
+
if total_height <= max_height || size <= 10
|
2161
|
+
return [lines.join("\n"), size]
|
2162
|
+
else
|
2163
|
+
size -= 2
|
2164
|
+
end
|
2165
|
+
end
|
2166
|
+
end
|
2167
|
+
|
2168
|
+
|
2093
2169
|
def image_text(text1, text2)
|
2094
2170
|
begin
|
2095
2171
|
color = File.open('./color.ini', 'r', :encoding => 'utf-8').read().split("\n")
|
2096
|
-
|
2097
|
-
|
2098
|
-
text = Magick::Draw.new
|
2172
|
+
font_files = Dir.entries('./fonts').select { |f| f.downcase.end_with?('.ttf') }
|
2173
|
+
font2 = './fonts/' + font_files.sample
|
2099
2174
|
color2 = color.sample
|
2100
|
-
|
2101
|
-
|
2175
|
+
|
2176
|
+
img = Magick::Image.read('./image/memory.png').first
|
2177
|
+
draw = Magick::Draw.new
|
2178
|
+
|
2179
|
+
raw_message = "#{text1}\n#{text2}".strip
|
2180
|
+
max_width = img.columns * 0.85
|
2181
|
+
max_height = img.rows * 0.6
|
2182
|
+
|
2102
2183
|
begin
|
2103
2184
|
size = rand(@data['이미지설정']['이미지글자1크기1'].text.to_i..@data['이미지설정']['이미지글자1크기2'].text.to_i)
|
2104
2185
|
rescue
|
2105
2186
|
size = 30
|
2106
2187
|
end
|
2188
|
+
|
2189
|
+
wrapped_message, adjusted_size = wrap_text_to_fit(draw, raw_message, max_width, max_height, font2, size)
|
2190
|
+
|
2107
2191
|
if @data['이미지설정']['글자그림자'].checked?
|
2108
|
-
img.annotate(
|
2109
|
-
|
2110
|
-
|
2111
|
-
|
2112
|
-
|
2192
|
+
img.annotate(draw, 0, 0, 2, 2, wrapped_message) do
|
2193
|
+
draw.gravity = Magick::CenterGravity
|
2194
|
+
draw.pointsize = adjusted_size
|
2195
|
+
draw.fill = '#000000'
|
2196
|
+
draw.font = font2
|
2113
2197
|
end
|
2114
2198
|
end
|
2115
|
-
|
2116
|
-
|
2117
|
-
|
2118
|
-
|
2199
|
+
|
2200
|
+
draw2 = Magick::Draw.new
|
2201
|
+
img.annotate(draw2, 0, 0, 0, 0, wrapped_message) do
|
2202
|
+
draw2.gravity = Magick::CenterGravity
|
2203
|
+
draw2.pointsize = adjusted_size
|
2204
|
+
draw2.fill = color2
|
2205
|
+
draw2.font = font2
|
2119
2206
|
if @data['이미지설정']['글자테두리'].checked?
|
2120
|
-
|
2121
|
-
|
2207
|
+
draw2.stroke_width = 2
|
2208
|
+
draw2.stroke = '#000000'
|
2122
2209
|
end
|
2123
|
-
text.fill = color2
|
2124
|
-
text.font = font2
|
2125
2210
|
end
|
2126
|
-
|
2211
|
+
|
2127
2212
|
img.write('./image/memory.png')
|
2128
2213
|
rescue
|
2129
2214
|
puts '이미지 폰트 불러오기 오류 재시도...'
|
@@ -2157,23 +2242,30 @@ class Wordpress
|
|
2157
2242
|
else
|
2158
2243
|
auto_image()
|
2159
2244
|
end
|
2160
|
-
|
2161
|
-
|
2245
|
+
|
2246
|
+
# '원본'을 포함한 이미지 크기 옵션 추가
|
2247
|
+
image_size = [480, 740, 650, 550, 480, 'original']
|
2162
2248
|
size = 0
|
2163
|
-
|
2249
|
+
|
2250
|
+
for n in 0..5 # 0부터 5까지 반복, '원본' 옵션까지 포함
|
2164
2251
|
if @data['image_size'][n].checked?
|
2165
|
-
if n ==
|
2166
|
-
size =
|
2252
|
+
if n == 5 # '원본'이 선택되었을 경우
|
2253
|
+
size = 'original'
|
2254
|
+
elsif n == 0
|
2255
|
+
size = image_size.sample # 랜덤 선택
|
2167
2256
|
else
|
2168
2257
|
size = image_size[n]
|
2169
2258
|
end
|
2170
2259
|
end
|
2171
2260
|
end
|
2261
|
+
|
2262
|
+
# '원본'이 선택되지 않았다면 기본 값 설정
|
2172
2263
|
if size == 0
|
2173
2264
|
size = 480
|
2174
2265
|
end
|
2266
|
+
|
2267
|
+
change_image_size(size) # 크기 변경 함수 호출
|
2175
2268
|
|
2176
|
-
change_image_size(size)
|
2177
2269
|
|
2178
2270
|
if @data['이미지설정']['필터사용'].checked?
|
2179
2271
|
image_filter()
|
@@ -2181,33 +2273,33 @@ class Wordpress
|
|
2181
2273
|
|
2182
2274
|
if @data['이미지설정']['글자삽입1'].checked?
|
2183
2275
|
if @data['이미지설정']['이미지글자1'].length == 0
|
2184
|
-
|
2276
|
+
image_text_path1 = ''
|
2185
2277
|
else
|
2186
|
-
|
2187
|
-
|
2188
|
-
|
2189
|
-
|
2190
|
-
|
2191
|
-
|
2192
|
-
|
2193
|
-
|
2194
|
-
|
2278
|
+
if @data['이미지설정']['글자랜덤'].checked?
|
2279
|
+
image_text_path1 = @data['이미지설정']['이미지글자1'].sample
|
2280
|
+
else
|
2281
|
+
image_text_path1 = @data['이미지설정']['이미지글자1'][@image_text_soon1]
|
2282
|
+
@image_text_soon1 += 1
|
2283
|
+
if @image_text_soon1 > @data['이미지설정']['이미지글자1'].length - 1
|
2284
|
+
@image_text_soon1 = 0
|
2285
|
+
end
|
2286
|
+
end
|
2195
2287
|
end
|
2196
2288
|
end
|
2197
2289
|
|
2198
2290
|
if @data['이미지설정']['글자삽입2'].checked?
|
2199
2291
|
if @data['이미지설정']['이미지글자2'].length == 0
|
2200
|
-
|
2201
|
-
else
|
2202
|
-
if @data['이미지설정']['글자랜덤'].checked?
|
2203
|
-
image_text_path2 = @data['이미지설정']['이미지글자2'].sample
|
2292
|
+
image_text_path2 = ''
|
2204
2293
|
else
|
2205
|
-
|
2206
|
-
|
2207
|
-
|
2208
|
-
|
2209
|
-
|
2210
|
-
|
2294
|
+
if @data['이미지설정']['글자랜덤'].checked?
|
2295
|
+
image_text_path2 = @data['이미지설정']['이미지글자2'].sample
|
2296
|
+
else
|
2297
|
+
image_text_path2 = @data['이미지설정']['이미지글자2'][@image_text_soon2]
|
2298
|
+
@image_text_soon2 += 1
|
2299
|
+
if @image_text_soon2 > @data['이미지설정']['이미지글자2'].length - 1
|
2300
|
+
@image_text_soon2 = 0
|
2301
|
+
end
|
2302
|
+
end
|
2211
2303
|
end
|
2212
2304
|
end
|
2213
2305
|
|
@@ -4571,6 +4663,7 @@ class Wordpress
|
|
4571
4663
|
@data['image_size'][2].checked = false
|
4572
4664
|
@data['image_size'][3].checked = false
|
4573
4665
|
@data['image_size'][4].checked = false
|
4666
|
+
@data['image_size'][5].checked = false
|
4574
4667
|
end
|
4575
4668
|
}
|
4576
4669
|
}
|
@@ -4581,6 +4674,7 @@ class Wordpress
|
|
4581
4674
|
@data['image_size'][2].checked = false
|
4582
4675
|
@data['image_size'][3].checked = false
|
4583
4676
|
@data['image_size'][4].checked = false
|
4677
|
+
@data['image_size'][5].checked = false
|
4584
4678
|
end
|
4585
4679
|
}
|
4586
4680
|
}
|
@@ -4591,6 +4685,7 @@ class Wordpress
|
|
4591
4685
|
@data['image_size'][0].checked = false
|
4592
4686
|
@data['image_size'][3].checked = false
|
4593
4687
|
@data['image_size'][4].checked = false
|
4688
|
+
@data['image_size'][5].checked = false
|
4594
4689
|
end
|
4595
4690
|
}
|
4596
4691
|
}
|
@@ -4601,6 +4696,7 @@ class Wordpress
|
|
4601
4696
|
@data['image_size'][2].checked = false
|
4602
4697
|
@data['image_size'][0].checked = false
|
4603
4698
|
@data['image_size'][4].checked = false
|
4699
|
+
@data['image_size'][5].checked = false
|
4604
4700
|
end
|
4605
4701
|
}
|
4606
4702
|
}
|
@@ -4611,6 +4707,18 @@ class Wordpress
|
|
4611
4707
|
@data['image_size'][2].checked = false
|
4612
4708
|
@data['image_size'][3].checked = false
|
4613
4709
|
@data['image_size'][0].checked = false
|
4710
|
+
@data['image_size'][5].checked = false
|
4711
|
+
end
|
4712
|
+
}
|
4713
|
+
}
|
4714
|
+
@data['image_size'][5] = checkbox('원본 px'){
|
4715
|
+
on_toggled{
|
4716
|
+
if @data['image_size'][5].checked?
|
4717
|
+
@data['image_size'][1].checked = false
|
4718
|
+
@data['image_size'][2].checked = false
|
4719
|
+
@data['image_size'][3].checked = false
|
4720
|
+
@data['image_size'][0].checked = false
|
4721
|
+
@data['image_size'][4].checked = false
|
4614
4722
|
end
|
4615
4723
|
}
|
4616
4724
|
}
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cafe_basics
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.50
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- zon
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-05-
|
10
|
+
date: 2025-05-30 00:00:00.000000000 Z
|
11
11
|
dependencies: []
|
12
12
|
description: File to Clipboard gem
|
13
13
|
email: mymin26@naver.com
|