wp_posting_zon 0.0.11 → 0.0.13
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/wp_posting_zon.rb +72 -245
- 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: f5f66606e7c15dd39601538be977010587b0d0724918f1adebfbe8469e3a12df
|
4
|
+
data.tar.gz: df6c76b2edd6f7f96081fa8ce546dcc6e8bbeaf2c27ad749f80e4b4ccd130b1a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d8d433bf91223f1393b2165594c3f4412d5c3712f01f03034fe855b0fc958f529a6c1911167d2aed49cc030a3cea4cdd8b32470749abc17ad3e80ab49b6647e
|
7
|
+
data.tar.gz: 1a21a9337fea50aaf4ae93ff3ae92a2f5a822e4c049406789b860a2f6eb2ed2f2a225011da3cb54ba729db87186edfb5e8bc7abe04a956848b2da902ac3da6bd
|
data/lib/wp_posting_zon.rb
CHANGED
@@ -447,7 +447,6 @@ class Wordpress
|
|
447
447
|
end
|
448
448
|
end
|
449
449
|
|
450
|
-
|
451
450
|
def color_image
|
452
451
|
color = File.open('./color.ini', 'r', :encoding => 'utf-8').read().split("\n")
|
453
452
|
image = Magick::Image.new(740, 740) { |k| k.background_color = color.sample }
|
@@ -456,188 +455,80 @@ class Wordpress
|
|
456
455
|
|
457
456
|
def save_image
|
458
457
|
if @data['이미지설정']['이미지'].length == 0
|
459
|
-
|
460
|
-
end
|
461
|
-
|
462
|
-
if @data['이미지설정']['순서사용'].checked?
|
463
|
-
image_path = @data['이미지설정']['이미지'][@image_counter][2]
|
464
|
-
@image_counter += 1
|
465
|
-
if @image_counter > @data['이미지설정']['이미지'].length - 1
|
466
|
-
@image_counter = 0
|
467
|
-
end
|
458
|
+
|
468
459
|
else
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
@
|
460
|
+
if @data['이미지설정']['순서사용'].checked?
|
461
|
+
image_path = @data['이미지설정']['이미지'][@image_counter][2]
|
462
|
+
@image_counter += 1
|
463
|
+
if @image_counter > @data['이미지설정']['이미지'].length-1
|
464
|
+
@image_counter = 0
|
465
|
+
end
|
466
|
+
else
|
467
|
+
image_path = @data['이미지설정']['이미지'].sample[2]
|
473
468
|
end
|
474
|
-
|
475
|
-
|
469
|
+
img = Magick::Image.read(image_path).first
|
470
|
+
img.write('./image/memory.png')
|
476
471
|
end
|
477
|
-
|
478
|
-
img = Magick::Image.read(image_path).first
|
479
|
-
img.write('./image/memory.png')
|
480
472
|
end
|
481
473
|
|
482
474
|
def change_image_size(w)
|
483
475
|
img = Magick::Image.read('./image/memory.png').first
|
484
476
|
width = img.columns
|
485
477
|
height = img.rows
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
begin
|
492
|
-
if @data['image_type'][0].checked? or @data['image_type'][2].checked?
|
493
|
-
# 비율을 맞추어 리사이징
|
494
|
-
img.resize!(w, w * (height.to_f / width.to_f))
|
495
|
-
else
|
496
|
-
# 정사각형으로 리사이징
|
497
|
-
img.resize!(w, w)
|
498
|
-
end
|
499
|
-
rescue
|
500
|
-
img.resize!(w, w) # 예외 처리 시에도 리사이징
|
478
|
+
begin
|
479
|
+
if @data['image_type'][0].checked? or @data['image_type'][2].checked?
|
480
|
+
img.resize!(w, w*(height.to_f/width.to_f))
|
481
|
+
else
|
482
|
+
img.resize!(w, w)
|
501
483
|
end
|
484
|
+
rescue
|
485
|
+
img.resize!(w, w)
|
502
486
|
end
|
503
|
-
|
504
|
-
# 리사이징된 이미지 저장
|
505
487
|
img.write('./image/memory.png')
|
506
488
|
end
|
507
489
|
|
508
|
-
def
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
if metrics.width > max_width
|
522
|
-
lines << line
|
523
|
-
line = char
|
524
|
-
else
|
525
|
-
line = test_line
|
526
|
-
end
|
490
|
+
def image_text(text1, text2)
|
491
|
+
begin
|
492
|
+
color = File.open('./color.ini', 'r', :encoding => 'utf-8').read().split("\n")
|
493
|
+
font = Dir.entries('./fonts')
|
494
|
+
img = Magick::Image.read('./image/memory.png').first
|
495
|
+
text = Magick::Draw.new
|
496
|
+
color2 = color.sample
|
497
|
+
font2 = './fonts/'+font.sample
|
498
|
+
message = text1.to_s+"\n"+text2.to_s
|
499
|
+
begin
|
500
|
+
size = rand(@data['이미지설정']['이미지글자1크기1'].text.to_i..@data['이미지설정']['이미지글자1크기2'].text.to_i)
|
501
|
+
rescue
|
502
|
+
size = 30
|
527
503
|
end
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
return [lines.join("\n"), size]
|
536
|
-
else
|
537
|
-
size -= 2
|
504
|
+
if @data['이미지설정']['글자그림자'].checked?
|
505
|
+
img.annotate(text, 0,0, +3,+3, message) do
|
506
|
+
text.gravity = Magick::CenterGravity
|
507
|
+
text.pointsize = size
|
508
|
+
text.fill = '#000000'
|
509
|
+
text.font = font2
|
510
|
+
end
|
538
511
|
end
|
539
|
-
end
|
540
|
-
end
|
541
|
-
|
542
|
-
|
543
|
-
def image_text(text1, text2)
|
544
|
-
begin
|
545
|
-
color = File.open('./color.ini', 'r', encoding: 'utf-8').read.split("\n").map(&:strip).reject(&:empty?)
|
546
|
-
font_files = Dir.entries('./fonts').select { |f| f.downcase.end_with?('.ttf') }
|
547
|
-
font2 = './fonts/' + font_files.sample
|
548
|
-
|
549
|
-
# 랜덤 글자색 선택
|
550
|
-
color2 = color.sample
|
551
|
-
|
552
|
-
# 헬퍼 함수: 색상 문자열 '#RRGGBB' -> [R,G,B] 배열로 변환
|
553
|
-
def hex_to_rgb(hex)
|
554
|
-
hex = hex.delete('#')
|
555
|
-
[hex[0..1], hex[2..3], hex[4..5]].map { |c| c.to_i(16) }
|
556
|
-
end
|
557
|
-
|
558
|
-
# 헬퍼 함수: 두 RGB 색상의 차이 계산 (간단한 유클리드 거리)
|
559
|
-
def color_distance(c1, c2)
|
560
|
-
Math.sqrt(
|
561
|
-
(c1[0] - c2[0])**2 +
|
562
|
-
(c1[1] - c2[1])**2 +
|
563
|
-
(c1[2] - c2[2])**2
|
564
|
-
)
|
565
|
-
end
|
566
|
-
|
567
|
-
# 대비가 충분히 되는 테두리 색상 선택
|
568
|
-
max_attempts = 10
|
569
|
-
stroke_color = nil
|
570
|
-
base_rgb = hex_to_rgb(color2)
|
571
|
-
|
572
|
-
max_attempts.times do
|
573
|
-
candidate = color.sample
|
574
|
-
candidate_rgb = hex_to_rgb(candidate)
|
575
|
-
dist = color_distance(base_rgb, candidate_rgb)
|
576
|
-
|
577
|
-
# 거리(차이) 임계값 100 (0~441 범위) — 필요시 조절 가능
|
578
|
-
if dist > 100
|
579
|
-
stroke_color = candidate
|
580
|
-
break
|
581
|
-
end
|
582
|
-
end
|
583
|
-
stroke_color ||= '#000000' # 만약 충분히 다른 색 없으면 검정색 기본값
|
584
|
-
|
585
|
-
img = Magick::Image.read('./image/memory.png').first
|
586
|
-
draw = Magick::Draw.new
|
587
512
|
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
513
|
+
img.annotate(text, 0,0,0,0, message) do
|
514
|
+
text.gravity = Magick::CenterGravity
|
515
|
+
text.pointsize = size
|
516
|
+
if @data['이미지설정']['글자테두리'].checked?
|
517
|
+
text.stroke_width = 2
|
518
|
+
text.stroke = '#000000'
|
519
|
+
end
|
520
|
+
text.fill = color2
|
521
|
+
text.font = font2
|
522
|
+
end
|
523
|
+
|
524
|
+
img.write('./image/memory.png')
|
594
525
|
rescue
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
wrapped_message, adjusted_size = wrap_text_to_fit(draw, raw_message, max_width, max_height, font2, size)
|
599
|
-
|
600
|
-
if @data['이미지설정']['글자그림자'].checked?
|
601
|
-
img.annotate(draw, 0, 0, 2, 2, wrapped_message) do
|
602
|
-
draw.gravity = Magick::CenterGravity
|
603
|
-
draw.pointsize = adjusted_size
|
604
|
-
draw.fill = '#000000'
|
605
|
-
draw.font = font2
|
606
|
-
end
|
526
|
+
puts '이미지 폰트 불러오기 오류 재시도...'
|
527
|
+
sleep(3)
|
528
|
+
retry
|
607
529
|
end
|
608
|
-
|
609
|
-
if @data['이미지설정']['글자테두리'].checked?
|
610
|
-
draw_stroke = Magick::Draw.new
|
611
|
-
img.annotate(draw_stroke, 0, 0, 0, 0, wrapped_message) do
|
612
|
-
draw_stroke.gravity = Magick::CenterGravity
|
613
|
-
draw_stroke.pointsize = adjusted_size
|
614
|
-
draw_stroke.fill = 'none'
|
615
|
-
draw_stroke.stroke = stroke_color
|
616
|
-
draw_stroke.stroke_width = rand(5..10)
|
617
|
-
draw_stroke.font = font2
|
618
|
-
end
|
619
|
-
end
|
620
|
-
|
621
|
-
draw2 = Magick::Draw.new
|
622
|
-
img.annotate(draw2, 0, 0, 0, 0, wrapped_message) do
|
623
|
-
draw2.gravity = Magick::CenterGravity
|
624
|
-
draw2.pointsize = adjusted_size
|
625
|
-
draw2.fill = color2
|
626
|
-
draw2.stroke = 'none'
|
627
|
-
draw2.font = font2
|
628
|
-
end
|
629
|
-
|
630
|
-
img.write('./image/memory.png')
|
631
|
-
|
632
|
-
rescue => e
|
633
|
-
puts "이미지 폰트 불러오기 오류 재시도... (#{e.message})"
|
634
|
-
sleep(3)
|
635
|
-
retry
|
636
|
-
end
|
637
530
|
end
|
638
531
|
|
639
|
-
|
640
|
-
|
641
532
|
def border()
|
642
533
|
color = File.open('./color.ini', 'r',:encoding => 'utf-8').read().split("\n")
|
643
534
|
img = Magick::Image.read('./image/memory.png').first
|
@@ -663,86 +554,48 @@ class Wordpress
|
|
663
554
|
else
|
664
555
|
auto_image()
|
665
556
|
end
|
666
|
-
|
667
|
-
|
668
|
-
image_size = [480, 740, 650, 550, 480, 'original']
|
557
|
+
|
558
|
+
image_size = [480,740,650,550,480]
|
669
559
|
size = 0
|
670
|
-
|
671
|
-
for n in 0..5 # 0부터 5까지 반복, '원본' 옵션까지 포함
|
560
|
+
for n in 0..4
|
672
561
|
if @data['image_size'][n].checked?
|
673
|
-
if n ==
|
674
|
-
size =
|
675
|
-
elsif n == 0
|
676
|
-
size = image_size.sample # 랜덤 선택
|
562
|
+
if n == 0
|
563
|
+
size = image_size.sample
|
677
564
|
else
|
678
565
|
size = image_size[n]
|
679
566
|
end
|
680
567
|
end
|
681
568
|
end
|
682
|
-
|
683
|
-
# '원본'이 선택되지 않았다면 기본 값 설정
|
684
569
|
if size == 0
|
685
570
|
size = 480
|
686
571
|
end
|
687
|
-
|
688
|
-
change_image_size(size) # 크기 변경 함수 호출
|
689
572
|
|
573
|
+
change_image_size(size)
|
690
574
|
|
691
575
|
if @data['이미지설정']['필터사용'].checked?
|
692
576
|
image_filter()
|
693
577
|
end
|
694
578
|
|
579
|
+
insert_image_text1 = ''
|
580
|
+
insert_image_text2 = ''
|
695
581
|
if @data['이미지설정']['글자삽입1'].checked?
|
696
|
-
|
697
|
-
image_text_path1 = ''
|
698
|
-
else
|
699
|
-
if @data['이미지설정']['글자랜덤'].checked?
|
700
|
-
image_text_path1 = @data['이미지설정']['이미지글자1'].sample
|
701
|
-
else
|
702
|
-
image_text_path1 = @data['이미지설정']['이미지글자1'][@image_text_soon1]
|
703
|
-
@image_text_soon1 += 1
|
704
|
-
if @image_text_soon1 > @data['이미지설정']['이미지글자1'].length - 1
|
705
|
-
@image_text_soon1 = 0
|
706
|
-
end
|
707
|
-
end
|
708
|
-
end
|
582
|
+
insert_image_text1 = @data['이미지설정']['이미지글자1'].sample
|
709
583
|
end
|
710
584
|
|
711
585
|
if @data['이미지설정']['글자삽입2'].checked?
|
712
|
-
|
713
|
-
image_text_path2 = ''
|
714
|
-
else
|
715
|
-
if @data['이미지설정']['글자랜덤'].checked?
|
716
|
-
image_text_path2 = @data['이미지설정']['이미지글자2'].sample
|
717
|
-
else
|
718
|
-
image_text_path2 = @data['이미지설정']['이미지글자2'][@image_text_soon2]
|
719
|
-
@image_text_soon2 += 1
|
720
|
-
if @image_text_soon2 > @data['이미지설정']['이미지글자2'].length - 1
|
721
|
-
@image_text_soon2 = 0
|
722
|
-
end
|
723
|
-
end
|
724
|
-
end
|
586
|
+
insert_image_text2 = @data['이미지설정']['이미지글자2'].sample
|
725
587
|
end
|
726
|
-
|
588
|
+
|
727
589
|
if @data['이미지설정']['글자삽입1'].checked? or @data['이미지설정']['글자삽입2'].checked?
|
728
|
-
image_text(
|
590
|
+
image_text(insert_image_text1, insert_image_text2)
|
729
591
|
end
|
730
592
|
|
731
593
|
if @data['이미지설정']['테두리사용'].checked?
|
732
594
|
border()
|
733
595
|
end
|
734
596
|
|
735
|
-
sleep(1)
|
736
597
|
time = Time.now.to_s.split(' ')[0..1].join('').split(':').join('').split('-').join('')
|
737
598
|
FileUtils.cp('./image/memory.png', './image/'+@keyword+time+'.png')
|
738
|
-
hi_dir = Dir.pwd
|
739
|
-
iconv = Iconv.new('UTF-8', 'CP949')
|
740
|
-
begin
|
741
|
-
hi_dir = iconv.iconv(hi_dir)
|
742
|
-
rescue
|
743
|
-
|
744
|
-
end
|
745
|
-
return hi_dir+'/image/'+@keyword+time+'.png'
|
746
599
|
end
|
747
600
|
|
748
601
|
def image_update22
|
@@ -2435,27 +2288,17 @@ class Wordpress
|
|
2435
2288
|
}
|
2436
2289
|
button('폴더째로불러오기'){
|
2437
2290
|
stretchy false
|
2438
|
-
on_clicked
|
2291
|
+
on_clicked{
|
2439
2292
|
path = @data['이미지설정']['폴더경로'].text.to_s.force_encoding('utf-8')
|
2293
|
+
Dir.entries(@data['이미지설정']['폴더경로'].text.to_s).each do |file|
|
2294
|
+
if file == '.' or file == '..'
|
2440
2295
|
|
2441
|
-
|
2442
|
-
|
2443
|
-
Dir.entries(path).each do |file|
|
2444
|
-
if file == '.' or file == '..'
|
2445
|
-
next
|
2446
|
-
else
|
2447
|
-
# 폴더 내의 파일을 이미지 리스트에 추가
|
2448
|
-
@data['이미지설정']['이미지'] << [false, file, path + "\\" + file.force_encoding('utf-8')]
|
2449
|
-
end
|
2296
|
+
else
|
2297
|
+
@data['이미지설정']['이미지'] << [false, file, path+"\\"+file.force_encoding('utf-8')]
|
2450
2298
|
end
|
2451
|
-
|
2452
|
-
# 마지막 빈 항목 추가 후 제거 (원래 로직에 맞춰)
|
2453
|
-
@data['이미지설정']['이미지'] << []
|
2454
|
-
@data['이미지설정']['이미지'].pop
|
2455
|
-
else
|
2456
|
-
# 경로가 존재하지 않으면 경고 메시지 출력
|
2457
|
-
puts "경로가 존재하지 않습니다: #{path}"
|
2458
2299
|
end
|
2300
|
+
@data['이미지설정']['이미지'] << []
|
2301
|
+
@data['이미지설정']['이미지'].pop
|
2459
2302
|
}
|
2460
2303
|
}
|
2461
2304
|
}
|
@@ -2603,7 +2446,6 @@ class Wordpress
|
|
2603
2446
|
@data['image_size'][2].checked = false
|
2604
2447
|
@data['image_size'][3].checked = false
|
2605
2448
|
@data['image_size'][4].checked = false
|
2606
|
-
@data['image_size'][5].checked = false
|
2607
2449
|
end
|
2608
2450
|
}
|
2609
2451
|
}
|
@@ -2614,7 +2456,6 @@ class Wordpress
|
|
2614
2456
|
@data['image_size'][2].checked = false
|
2615
2457
|
@data['image_size'][3].checked = false
|
2616
2458
|
@data['image_size'][4].checked = false
|
2617
|
-
@data['image_size'][5].checked = false
|
2618
2459
|
end
|
2619
2460
|
}
|
2620
2461
|
}
|
@@ -2625,7 +2466,6 @@ class Wordpress
|
|
2625
2466
|
@data['image_size'][0].checked = false
|
2626
2467
|
@data['image_size'][3].checked = false
|
2627
2468
|
@data['image_size'][4].checked = false
|
2628
|
-
@data['image_size'][5].checked = false
|
2629
2469
|
end
|
2630
2470
|
}
|
2631
2471
|
}
|
@@ -2636,7 +2476,6 @@ class Wordpress
|
|
2636
2476
|
@data['image_size'][2].checked = false
|
2637
2477
|
@data['image_size'][0].checked = false
|
2638
2478
|
@data['image_size'][4].checked = false
|
2639
|
-
@data['image_size'][5].checked = false
|
2640
2479
|
end
|
2641
2480
|
}
|
2642
2481
|
}
|
@@ -2647,18 +2486,6 @@ class Wordpress
|
|
2647
2486
|
@data['image_size'][2].checked = false
|
2648
2487
|
@data['image_size'][3].checked = false
|
2649
2488
|
@data['image_size'][0].checked = false
|
2650
|
-
@data['image_size'][5].checked = false
|
2651
|
-
end
|
2652
|
-
}
|
2653
|
-
}
|
2654
|
-
@data['image_size'][5] = checkbox('원본 px'){
|
2655
|
-
on_toggled{
|
2656
|
-
if @data['image_size'][5].checked?
|
2657
|
-
@data['image_size'][1].checked = false
|
2658
|
-
@data['image_size'][2].checked = false
|
2659
|
-
@data['image_size'][3].checked = false
|
2660
|
-
@data['image_size'][0].checked = false
|
2661
|
-
@data['image_size'][4].checked = false
|
2662
2489
|
end
|
2663
2490
|
}
|
2664
2491
|
}
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wp_posting_zon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- zon
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-
|
10
|
+
date: 2025-07-02 00:00:00.000000000 Z
|
11
11
|
dependencies: []
|
12
12
|
description: File to Clipboard gem
|
13
13
|
email: mymin26@naver.com
|