nblog_zon 111.117.789 → 111.117.899

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/nblog_zon.rb +107 -63
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b8fa0de35ccb453ed183232c89506cc94d1e862495dbb7398100ac52848cfe64
4
- data.tar.gz: 8dbca3b1ce745f549c442dfb0b3204c7ced2dcadca999ed05bbe23ff746c009f
3
+ metadata.gz: 3042209d1cdf1891eb123205e1654e8fb4703412602f4709cdc3458da3e69ca7
4
+ data.tar.gz: 2837fed48bec16b723f325bbde547b999a9eaec90d8874e471590e8b23b0db8c
5
5
  SHA512:
6
- metadata.gz: 37d160408f39c74f0598e6d1eab6f01373a2f69a2f851c60dd382cb3d7ac0afe8fccdb2a724c29401429a4d94413d8b7af1401fdc8697400cb24a44aa79018cc
7
- data.tar.gz: 5699d00b22583c92f3cc9333038315c33aa659193860dad395bef83e592fb71228ad8d6e1f2e4812b964ed6445c79f0fa0a28403b6605d16f84058080cf987c4
6
+ metadata.gz: 26a4779ec8e13b7cb5b33d09e0f9b8d214d5387e9b176a39c5c5cb30d0835fae3462dbd6c4b7fcbf53ac74ae7449bde58f60f63a52f27295dd70c50fc85d2fb8
7
+ data.tar.gz: 40b5e8eb499ab2a48483ccb06c014ee3241d064d969c612592c9b9fa9cc722318ac74eda16cd3623351516ceb497eb1aad114e91888bb0bc9f6f249f1b583750
data/lib/nblog_zon.rb CHANGED
@@ -243,37 +243,37 @@ end
243
243
  class Naver
244
244
  def initialize
245
245
  @seed = 1
246
- kill_selenium_chrome #기존 창 모두 닫는 명령
247
- sleep(1)
246
+ #kill_selenium_chrome #기존 창 모두 닫는 명령
247
+ #sleep(1)
248
248
  end
249
249
 
250
- def kill_selenium_chrome #기존 창 모두 닫는 코드
251
- wmi = WIN32OLE.connect("winmgmts://")
252
- chrome_procs = wmi.ExecQuery("SELECT * FROM Win32_Process WHERE Name = 'chrome.exe'")
250
+ #def kill_selenium_chrome #기존 창 모두 닫는 코드
251
+ # wmi = WIN32OLE.connect("winmgmts://")
252
+ # chrome_procs = wmi.ExecQuery("SELECT * FROM Win32_Process WHERE Name = 'chrome.exe'")
253
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
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
261
  #puts "→ 이미 종료된 프로세스: #{proc.ProcessId}"
262
- end
263
- end
264
- end
262
+ # end
263
+ # end
264
+ # end
265
265
 
266
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
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
273
  #puts "→ 이미 종료된 chromedriver: #{proc.ProcessId}"
274
- end
275
- end
276
- end
274
+ # end
275
+ # end
276
+ #end
277
277
 
278
278
  def chrome_setup(user_id, proxy)
279
279
  naver_cookie_dir = "C:/naver_cookie"
@@ -2319,40 +2319,84 @@ class Wordpress
2319
2319
  img.write('./image/memory.png')
2320
2320
  end
2321
2321
 
2322
+ def wrap_text_to_fit(draw, text, max_width, max_height, font_path, initial_size)
2323
+ size = initial_size
2324
+ draw.font = font_path
2325
+
2326
+ loop do
2327
+ draw.pointsize = size
2328
+ words = text.chars # 글자 단위로 자름 (한국어 기준)
2329
+ lines = []
2330
+ line = ""
2331
+
2332
+ words.each do |char|
2333
+ test_line = line + char
2334
+ metrics = draw.get_type_metrics(test_line)
2335
+ if metrics.width > max_width
2336
+ lines << line
2337
+ line = char
2338
+ else
2339
+ line = test_line
2340
+ end
2341
+ end
2342
+ lines << line unless line.empty?
2343
+
2344
+ line_height = draw.get_type_metrics("가").height
2345
+ total_height = line_height * lines.size
2346
+
2347
+ # 세로 초과 안 하면 성공
2348
+ if total_height <= max_height || size <= 10
2349
+ return [lines.join("\n"), size]
2350
+ else
2351
+ size -= 2
2352
+ end
2353
+ end
2354
+ end
2355
+
2356
+
2322
2357
  def image_text(text1, text2)
2323
2358
  begin
2324
2359
  color = File.open('./color.ini', 'r', :encoding => 'utf-8').read().split("\n")
2325
- font = Dir.entries('./fonts')
2326
- img = Magick::Image.read('./image/memory.png').first
2327
- text = Magick::Draw.new
2360
+ font_files = Dir.entries('./fonts').select { |f| f.downcase.end_with?('.ttf') }
2361
+ font2 = './fonts/' + font_files.sample
2328
2362
  color2 = color.sample
2329
- font2 = './fonts/'+font.sample
2330
- message = text1.to_s+"\n"+text2.to_s
2363
+
2364
+ img = Magick::Image.read('./image/memory.png').first
2365
+ draw = Magick::Draw.new
2366
+
2367
+ raw_message = "#{text1}\n#{text2}".strip
2368
+ max_width = img.columns * 0.85
2369
+ max_height = img.rows * 0.6
2370
+
2331
2371
  begin
2332
2372
  size = rand(@data['이미지설정']['이미지글자1크기1'].text.to_i..@data['이미지설정']['이미지글자1크기2'].text.to_i)
2333
2373
  rescue
2334
2374
  size = 30
2335
2375
  end
2376
+
2377
+ wrapped_message, adjusted_size = wrap_text_to_fit(draw, raw_message, max_width, max_height, font2, size)
2378
+
2336
2379
  if @data['이미지설정']['글자그림자'].checked?
2337
- img.annotate(text, 0,0, +3,+3, message) do
2338
- text.gravity = Magick::CenterGravity
2339
- text.pointsize = size
2340
- text.fill = '#000000'
2341
- text.font = font2
2380
+ img.annotate(draw, 0, 0, 2, 2, wrapped_message) do
2381
+ draw.gravity = Magick::CenterGravity
2382
+ draw.pointsize = adjusted_size
2383
+ draw.fill = '#000000'
2384
+ draw.font = font2
2342
2385
  end
2343
2386
  end
2344
-
2345
- img.annotate(text, 0,0,0,0, message) do
2346
- text.gravity = Magick::CenterGravity
2347
- text.pointsize = size
2387
+
2388
+ draw2 = Magick::Draw.new
2389
+ img.annotate(draw2, 0, 0, 0, 0, wrapped_message) do
2390
+ draw2.gravity = Magick::CenterGravity
2391
+ draw2.pointsize = adjusted_size
2392
+ draw2.fill = color2
2393
+ draw2.font = font2
2348
2394
  if @data['이미지설정']['글자테두리'].checked?
2349
- text.stroke_width = 2
2350
- text.stroke = '#000000'
2395
+ draw2.stroke_width = 2
2396
+ draw2.stroke = '#000000'
2351
2397
  end
2352
- text.fill = color2
2353
- text.font = font2
2354
2398
  end
2355
-
2399
+
2356
2400
  img.write('./image/memory.png')
2357
2401
  rescue
2358
2402
  puts '이미지 폰트 불러오기 오류 재시도...'
@@ -2417,33 +2461,33 @@ class Wordpress
2417
2461
 
2418
2462
  if @data['이미지설정']['글자삽입1'].checked?
2419
2463
  if @data['이미지설정']['이미지글자1'].length == 0
2420
- image_text_path1 = ''
2464
+ image_text_path1 = ''
2421
2465
  else
2422
- if @data['이미지설정']['글자랜덤'].checked?
2423
- image_text_path1 = @data['이미지설정']['이미지글자1'].sample
2424
- else
2425
- image_text_path1 = @data['이미지설정']['이미지글자1'][@image_text_soon1]
2426
- @image_text_soon1 += 1
2427
- if @image_text_soon1 > @data['이미지설정']['이미지글자1'].length - 1
2428
- @image_text_soon1 = 0
2429
- end
2430
- end
2466
+ if @data['이미지설정']['글자랜덤'].checked?
2467
+ image_text_path1 = @data['이미지설정']['이미지글자1'].sample
2468
+ else
2469
+ image_text_path1 = @data['이미지설정']['이미지글자1'][@image_text_soon1]
2470
+ @image_text_soon1 += 1
2471
+ if @image_text_soon1 > @data['이미지설정']['이미지글자1'].length - 1
2472
+ @image_text_soon1 = 0
2473
+ end
2474
+ end
2431
2475
  end
2432
2476
  end
2433
2477
 
2434
2478
  if @data['이미지설정']['글자삽입2'].checked?
2435
2479
  if @data['이미지설정']['이미지글자2'].length == 0
2436
- image_text_path2 = ''
2480
+ image_text_path2 = ''
2437
2481
  else
2438
- if @data['이미지설정']['글자랜덤'].checked?
2439
- image_text_path2 = @data['이미지설정']['이미지글자2'].sample
2440
- else
2441
- image_text_path2 = @data['이미지설정']['이미지글자2'][@image_text_soon2]
2442
- @image_text_soon2 += 1
2443
- if @image_text_soon2 > @data['이미지설정']['이미지글자2'].length - 1
2444
- @image_text_soon2 = 0
2445
- end
2446
- end
2482
+ if @data['이미지설정']['글자랜덤'].checked?
2483
+ image_text_path2 = @data['이미지설정']['이미지글자2'].sample
2484
+ else
2485
+ image_text_path2 = @data['이미지설정']['이미지글자2'][@image_text_soon2]
2486
+ @image_text_soon2 += 1
2487
+ if @image_text_soon2 > @data['이미지설정']['이미지글자2'].length - 1
2488
+ @image_text_soon2 = 0
2489
+ end
2490
+ end
2447
2491
  end
2448
2492
  end
2449
2493
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nblog_zon
3
3
  version: !ruby/object:Gem::Version
4
- version: 111.117.789
4
+ version: 111.117.899
5
5
  platform: ruby
6
6
  authors:
7
7
  - zon
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-05-29 00:00:00.000000000 Z
10
+ date: 2025-05-30 00:00:00.000000000 Z
11
11
  dependencies: []
12
12
  description: File to Clipboard gem
13
13
  email: rnjstnswp123@naver.com