wp_posting_duo 0.0.10 → 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_duo.rb +91 -260
- 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: 484347fe6285924f3c72ca0d2bcc9ff657e10b74d53d91fa2504f87ed5e88ede
|
4
|
+
data.tar.gz: 5969bceea54588cde40d9fffad780d0bca877fc1719f90524b78d02b2e23f1dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36113eb3895963e4823858e058045cb26a1d0f948f1a4406d890b9aefbc44d585f51f73d9820a161235b583a166d83ed2c94a35999154fbc4373409205bb3db1
|
7
|
+
data.tar.gz: 123a95dac0facd827db318f076dc90cdfa5380122b787d1637b7833dfc6332a4d5a2c6074cf5c6a9c8d874639b215f6663c0d25193d6ba679d2732784e4256ee
|
data/lib/wp_posting_duo.rb
CHANGED
@@ -404,24 +404,28 @@ class Wordpress
|
|
404
404
|
end
|
405
405
|
|
406
406
|
def crop_image_height_under_width(path, min_crop_ratio = 0.625)
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
407
|
+
img = Magick::Image.read(path).first
|
408
|
+
width = img.columns
|
409
|
+
height = img.rows
|
412
410
|
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
411
|
+
if height > width
|
412
|
+
min_height = (width * min_crop_ratio).to_i
|
413
|
+
new_height = rand(min_height..width)
|
414
|
+
crop_top = ((height - new_height) / 2.0).round
|
417
415
|
|
418
|
-
|
419
|
-
cropped.write(path)
|
416
|
+
cropped = img.crop(0, crop_top, width, new_height, true)
|
420
417
|
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
418
|
+
retries = 0
|
419
|
+
begin
|
420
|
+
cropped.write(path)
|
421
|
+
rescue => e
|
422
|
+
retries += 1
|
423
|
+
puts "이미지 저장 오류 (#{e.message}), 재시도 #{retries}/5"
|
424
|
+
sleep(1)
|
425
|
+
retry if retries < 5
|
426
|
+
raise "이미지 저장 실패: #{e.message}"
|
427
|
+
end
|
428
|
+
end
|
425
429
|
end
|
426
430
|
|
427
431
|
def auto_image(keyword = nil)
|
@@ -508,7 +512,6 @@ class Wordpress
|
|
508
512
|
end
|
509
513
|
end
|
510
514
|
|
511
|
-
|
512
515
|
def color_image
|
513
516
|
color = File.open('./color.ini', 'r', :encoding => 'utf-8').read().split("\n")
|
514
517
|
image = Magick::Image.new(740, 740) { |k| k.background_color = color.sample }
|
@@ -517,188 +520,80 @@ class Wordpress
|
|
517
520
|
|
518
521
|
def save_image
|
519
522
|
if @data['이미지설정']['이미지'].length == 0
|
520
|
-
|
521
|
-
end
|
522
|
-
|
523
|
-
if @data['이미지설정']['순서사용'].checked?
|
524
|
-
image_path = @data['이미지설정']['이미지'][@image_counter][2]
|
525
|
-
@image_counter += 1
|
526
|
-
if @image_counter > @data['이미지설정']['이미지'].length - 1
|
527
|
-
@image_counter = 0
|
528
|
-
end
|
523
|
+
|
529
524
|
else
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
@
|
525
|
+
if @data['이미지설정']['순서사용'].checked?
|
526
|
+
image_path = @data['이미지설정']['이미지'][@image_counter][2]
|
527
|
+
@image_counter += 1
|
528
|
+
if @image_counter > @data['이미지설정']['이미지'].length-1
|
529
|
+
@image_counter = 0
|
530
|
+
end
|
531
|
+
else
|
532
|
+
image_path = @data['이미지설정']['이미지'].sample[2]
|
534
533
|
end
|
535
|
-
|
536
|
-
|
534
|
+
img = Magick::Image.read(image_path).first
|
535
|
+
img.write('./image/memory.png')
|
537
536
|
end
|
538
|
-
|
539
|
-
img = Magick::Image.read(image_path).first
|
540
|
-
img.write('./image/memory.png')
|
541
537
|
end
|
542
538
|
|
543
539
|
def change_image_size(w)
|
544
540
|
img = Magick::Image.read('./image/memory.png').first
|
545
541
|
width = img.columns
|
546
542
|
height = img.rows
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
begin
|
553
|
-
if @data['image_type'][0].checked? or @data['image_type'][2].checked?
|
554
|
-
# 비율을 맞추어 리사이징
|
555
|
-
img.resize!(w, w * (height.to_f / width.to_f))
|
556
|
-
else
|
557
|
-
# 정사각형으로 리사이징
|
558
|
-
img.resize!(w, w)
|
559
|
-
end
|
560
|
-
rescue
|
561
|
-
img.resize!(w, w) # 예외 처리 시에도 리사이징
|
543
|
+
begin
|
544
|
+
if @data['image_type'][0].checked? or @data['image_type'][2].checked?
|
545
|
+
img.resize!(w, w*(height.to_f/width.to_f))
|
546
|
+
else
|
547
|
+
img.resize!(w, w)
|
562
548
|
end
|
549
|
+
rescue
|
550
|
+
img.resize!(w, w)
|
563
551
|
end
|
564
|
-
|
565
|
-
# 리사이징된 이미지 저장
|
566
552
|
img.write('./image/memory.png')
|
567
553
|
end
|
568
554
|
|
569
|
-
def
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
if metrics.width > max_width
|
583
|
-
lines << line
|
584
|
-
line = char
|
585
|
-
else
|
586
|
-
line = test_line
|
587
|
-
end
|
555
|
+
def image_text(text1, text2)
|
556
|
+
begin
|
557
|
+
color = File.open('./color.ini', 'r', :encoding => 'utf-8').read().split("\n")
|
558
|
+
font = Dir.entries('./fonts')
|
559
|
+
img = Magick::Image.read('./image/memory.png').first
|
560
|
+
text = Magick::Draw.new
|
561
|
+
color2 = color.sample
|
562
|
+
font2 = './fonts/'+font.sample
|
563
|
+
message = text1.to_s+"\n"+text2.to_s
|
564
|
+
begin
|
565
|
+
size = rand(@data['이미지설정']['이미지글자1크기1'].text.to_i..@data['이미지설정']['이미지글자1크기2'].text.to_i)
|
566
|
+
rescue
|
567
|
+
size = 30
|
588
568
|
end
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
return [lines.join("\n"), size]
|
597
|
-
else
|
598
|
-
size -= 2
|
569
|
+
if @data['이미지설정']['글자그림자'].checked?
|
570
|
+
img.annotate(text, 0,0, +3,+3, message) do
|
571
|
+
text.gravity = Magick::CenterGravity
|
572
|
+
text.pointsize = size
|
573
|
+
text.fill = '#000000'
|
574
|
+
text.font = font2
|
575
|
+
end
|
599
576
|
end
|
600
|
-
end
|
601
|
-
end
|
602
|
-
|
603
|
-
|
604
|
-
def image_text(text1, text2)
|
605
|
-
begin
|
606
|
-
color = File.open('./color.ini', 'r', encoding: 'utf-8').read.split("\n").map(&:strip).reject(&:empty?)
|
607
|
-
font_files = Dir.entries('./fonts').select { |f| f.downcase.end_with?('.ttf') }
|
608
|
-
font2 = './fonts/' + font_files.sample
|
609
|
-
|
610
|
-
# 랜덤 글자색 선택
|
611
|
-
color2 = color.sample
|
612
|
-
|
613
|
-
# 헬퍼 함수: 색상 문자열 '#RRGGBB' -> [R,G,B] 배열로 변환
|
614
|
-
def hex_to_rgb(hex)
|
615
|
-
hex = hex.delete('#')
|
616
|
-
[hex[0..1], hex[2..3], hex[4..5]].map { |c| c.to_i(16) }
|
617
|
-
end
|
618
|
-
|
619
|
-
# 헬퍼 함수: 두 RGB 색상의 차이 계산 (간단한 유클리드 거리)
|
620
|
-
def color_distance(c1, c2)
|
621
|
-
Math.sqrt(
|
622
|
-
(c1[0] - c2[0])**2 +
|
623
|
-
(c1[1] - c2[1])**2 +
|
624
|
-
(c1[2] - c2[2])**2
|
625
|
-
)
|
626
|
-
end
|
627
|
-
|
628
|
-
# 대비가 충분히 되는 테두리 색상 선택
|
629
|
-
max_attempts = 10
|
630
|
-
stroke_color = nil
|
631
|
-
base_rgb = hex_to_rgb(color2)
|
632
|
-
|
633
|
-
max_attempts.times do
|
634
|
-
candidate = color.sample
|
635
|
-
candidate_rgb = hex_to_rgb(candidate)
|
636
|
-
dist = color_distance(base_rgb, candidate_rgb)
|
637
|
-
|
638
|
-
# 거리(차이) 임계값 100 (0~441 범위) — 필요시 조절 가능
|
639
|
-
if dist > 100
|
640
|
-
stroke_color = candidate
|
641
|
-
break
|
642
|
-
end
|
643
|
-
end
|
644
|
-
stroke_color ||= '#000000' # 만약 충분히 다른 색 없으면 검정색 기본값
|
645
|
-
|
646
|
-
img = Magick::Image.read('./image/memory.png').first
|
647
|
-
draw = Magick::Draw.new
|
648
|
-
|
649
|
-
raw_message = "#{text1}\n#{text2}".strip
|
650
|
-
max_width = img.columns * 0.85
|
651
|
-
max_height = img.rows * 0.6
|
652
577
|
|
653
|
-
|
654
|
-
|
578
|
+
img.annotate(text, 0,0,0,0, message) do
|
579
|
+
text.gravity = Magick::CenterGravity
|
580
|
+
text.pointsize = size
|
581
|
+
if @data['이미지설정']['글자테두리'].checked?
|
582
|
+
text.stroke_width = 2
|
583
|
+
text.stroke = '#000000'
|
584
|
+
end
|
585
|
+
text.fill = color2
|
586
|
+
text.font = font2
|
587
|
+
end
|
588
|
+
|
589
|
+
img.write('./image/memory.png')
|
655
590
|
rescue
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
wrapped_message, adjusted_size = wrap_text_to_fit(draw, raw_message, max_width, max_height, font2, size)
|
660
|
-
|
661
|
-
if @data['이미지설정']['글자그림자'].checked?
|
662
|
-
img.annotate(draw, 0, 0, 2, 2, wrapped_message) do
|
663
|
-
draw.gravity = Magick::CenterGravity
|
664
|
-
draw.pointsize = adjusted_size
|
665
|
-
draw.fill = '#000000'
|
666
|
-
draw.font = font2
|
667
|
-
end
|
668
|
-
end
|
669
|
-
|
670
|
-
if @data['이미지설정']['글자테두리'].checked?
|
671
|
-
draw_stroke = Magick::Draw.new
|
672
|
-
img.annotate(draw_stroke, 0, 0, 0, 0, wrapped_message) do
|
673
|
-
draw_stroke.gravity = Magick::CenterGravity
|
674
|
-
draw_stroke.pointsize = adjusted_size
|
675
|
-
draw_stroke.fill = 'none'
|
676
|
-
draw_stroke.stroke = stroke_color
|
677
|
-
draw_stroke.stroke_width = rand(5..10)
|
678
|
-
draw_stroke.font = font2
|
679
|
-
end
|
591
|
+
puts '이미지 폰트 불러오기 오류 재시도...'
|
592
|
+
sleep(3)
|
593
|
+
retry
|
680
594
|
end
|
681
|
-
|
682
|
-
draw2 = Magick::Draw.new
|
683
|
-
img.annotate(draw2, 0, 0, 0, 0, wrapped_message) do
|
684
|
-
draw2.gravity = Magick::CenterGravity
|
685
|
-
draw2.pointsize = adjusted_size
|
686
|
-
draw2.fill = color2
|
687
|
-
draw2.stroke = 'none'
|
688
|
-
draw2.font = font2
|
689
|
-
end
|
690
|
-
|
691
|
-
img.write('./image/memory.png')
|
692
|
-
|
693
|
-
rescue => e
|
694
|
-
puts "이미지 폰트 불러오기 오류 재시도... (#{e.message})"
|
695
|
-
sleep(3)
|
696
|
-
retry
|
697
|
-
end
|
698
595
|
end
|
699
596
|
|
700
|
-
|
701
|
-
|
702
597
|
def border()
|
703
598
|
color = File.open('./color.ini', 'r',:encoding => 'utf-8').read().split("\n")
|
704
599
|
img = Magick::Image.read('./image/memory.png').first
|
@@ -724,86 +619,48 @@ class Wordpress
|
|
724
619
|
else
|
725
620
|
auto_image()
|
726
621
|
end
|
727
|
-
|
728
|
-
|
729
|
-
image_size = [480, 740, 650, 550, 480, 'original']
|
622
|
+
|
623
|
+
image_size = [480,740,650,550,480]
|
730
624
|
size = 0
|
731
|
-
|
732
|
-
for n in 0..5 # 0부터 5까지 반복, '원본' 옵션까지 포함
|
625
|
+
for n in 0..4
|
733
626
|
if @data['image_size'][n].checked?
|
734
|
-
if n ==
|
735
|
-
size =
|
736
|
-
elsif n == 0
|
737
|
-
size = image_size.sample # 랜덤 선택
|
627
|
+
if n == 0
|
628
|
+
size = image_size.sample
|
738
629
|
else
|
739
630
|
size = image_size[n]
|
740
631
|
end
|
741
632
|
end
|
742
633
|
end
|
743
|
-
|
744
|
-
# '원본'이 선택되지 않았다면 기본 값 설정
|
745
634
|
if size == 0
|
746
635
|
size = 480
|
747
636
|
end
|
748
|
-
|
749
|
-
change_image_size(size) # 크기 변경 함수 호출
|
750
637
|
|
638
|
+
change_image_size(size)
|
751
639
|
|
752
640
|
if @data['이미지설정']['필터사용'].checked?
|
753
641
|
image_filter()
|
754
642
|
end
|
755
643
|
|
644
|
+
insert_image_text1 = ''
|
645
|
+
insert_image_text2 = ''
|
756
646
|
if @data['이미지설정']['글자삽입1'].checked?
|
757
|
-
|
758
|
-
image_text_path1 = ''
|
759
|
-
else
|
760
|
-
if @data['이미지설정']['글자랜덤'].checked?
|
761
|
-
image_text_path1 = @data['이미지설정']['이미지글자1'].sample
|
762
|
-
else
|
763
|
-
image_text_path1 = @data['이미지설정']['이미지글자1'][@image_text_soon1]
|
764
|
-
@image_text_soon1 += 1
|
765
|
-
if @image_text_soon1 > @data['이미지설정']['이미지글자1'].length - 1
|
766
|
-
@image_text_soon1 = 0
|
767
|
-
end
|
768
|
-
end
|
769
|
-
end
|
647
|
+
insert_image_text1 = @data['이미지설정']['이미지글자1'].sample
|
770
648
|
end
|
771
649
|
|
772
650
|
if @data['이미지설정']['글자삽입2'].checked?
|
773
|
-
|
774
|
-
image_text_path2 = ''
|
775
|
-
else
|
776
|
-
if @data['이미지설정']['글자랜덤'].checked?
|
777
|
-
image_text_path2 = @data['이미지설정']['이미지글자2'].sample
|
778
|
-
else
|
779
|
-
image_text_path2 = @data['이미지설정']['이미지글자2'][@image_text_soon2]
|
780
|
-
@image_text_soon2 += 1
|
781
|
-
if @image_text_soon2 > @data['이미지설정']['이미지글자2'].length - 1
|
782
|
-
@image_text_soon2 = 0
|
783
|
-
end
|
784
|
-
end
|
785
|
-
end
|
651
|
+
insert_image_text2 = @data['이미지설정']['이미지글자2'].sample
|
786
652
|
end
|
787
|
-
|
653
|
+
|
788
654
|
if @data['이미지설정']['글자삽입1'].checked? or @data['이미지설정']['글자삽입2'].checked?
|
789
|
-
image_text(
|
655
|
+
image_text(insert_image_text1, insert_image_text2)
|
790
656
|
end
|
791
657
|
|
792
658
|
if @data['이미지설정']['테두리사용'].checked?
|
793
659
|
border()
|
794
660
|
end
|
795
661
|
|
796
|
-
sleep(1)
|
797
662
|
time = Time.now.to_s.split(' ')[0..1].join('').split(':').join('').split('-').join('')
|
798
663
|
FileUtils.cp('./image/memory.png', './image/'+@keyword+time+'.png')
|
799
|
-
hi_dir = Dir.pwd
|
800
|
-
iconv = Iconv.new('UTF-8', 'CP949')
|
801
|
-
begin
|
802
|
-
hi_dir = iconv.iconv(hi_dir)
|
803
|
-
rescue
|
804
|
-
|
805
|
-
end
|
806
|
-
return hi_dir+'/image/'+@keyword+time+'.png'
|
807
664
|
end
|
808
665
|
|
809
666
|
def image_update22
|
@@ -2502,27 +2359,17 @@ class Wordpress
|
|
2502
2359
|
}
|
2503
2360
|
button('폴더째로불러오기'){
|
2504
2361
|
stretchy false
|
2505
|
-
on_clicked
|
2362
|
+
on_clicked{
|
2506
2363
|
path = @data['이미지설정']['폴더경로'].text.to_s.force_encoding('utf-8')
|
2364
|
+
Dir.entries(@data['이미지설정']['폴더경로'].text.to_s).each do |file|
|
2365
|
+
if file == '.' or file == '..'
|
2507
2366
|
|
2508
|
-
|
2509
|
-
|
2510
|
-
Dir.entries(path).each do |file|
|
2511
|
-
if file == '.' or file == '..'
|
2512
|
-
next
|
2513
|
-
else
|
2514
|
-
# 폴더 내의 파일을 이미지 리스트에 추가
|
2515
|
-
@data['이미지설정']['이미지'] << [false, file, path + "\\" + file.force_encoding('utf-8')]
|
2516
|
-
end
|
2367
|
+
else
|
2368
|
+
@data['이미지설정']['이미지'] << [false, file, path+"\\"+file.force_encoding('utf-8')]
|
2517
2369
|
end
|
2518
|
-
|
2519
|
-
# 마지막 빈 항목 추가 후 제거 (원래 로직에 맞춰)
|
2520
|
-
@data['이미지설정']['이미지'] << []
|
2521
|
-
@data['이미지설정']['이미지'].pop
|
2522
|
-
else
|
2523
|
-
# 경로가 존재하지 않으면 경고 메시지 출력
|
2524
|
-
puts "경로가 존재하지 않습니다: #{path}"
|
2525
2370
|
end
|
2371
|
+
@data['이미지설정']['이미지'] << []
|
2372
|
+
@data['이미지설정']['이미지'].pop
|
2526
2373
|
}
|
2527
2374
|
}
|
2528
2375
|
}
|
@@ -2670,7 +2517,6 @@ class Wordpress
|
|
2670
2517
|
@data['image_size'][2].checked = false
|
2671
2518
|
@data['image_size'][3].checked = false
|
2672
2519
|
@data['image_size'][4].checked = false
|
2673
|
-
@data['image_size'][5].checked = false
|
2674
2520
|
end
|
2675
2521
|
}
|
2676
2522
|
}
|
@@ -2681,7 +2527,6 @@ class Wordpress
|
|
2681
2527
|
@data['image_size'][2].checked = false
|
2682
2528
|
@data['image_size'][3].checked = false
|
2683
2529
|
@data['image_size'][4].checked = false
|
2684
|
-
@data['image_size'][5].checked = false
|
2685
2530
|
end
|
2686
2531
|
}
|
2687
2532
|
}
|
@@ -2692,7 +2537,6 @@ class Wordpress
|
|
2692
2537
|
@data['image_size'][0].checked = false
|
2693
2538
|
@data['image_size'][3].checked = false
|
2694
2539
|
@data['image_size'][4].checked = false
|
2695
|
-
@data['image_size'][5].checked = false
|
2696
2540
|
end
|
2697
2541
|
}
|
2698
2542
|
}
|
@@ -2703,7 +2547,6 @@ class Wordpress
|
|
2703
2547
|
@data['image_size'][2].checked = false
|
2704
2548
|
@data['image_size'][0].checked = false
|
2705
2549
|
@data['image_size'][4].checked = false
|
2706
|
-
@data['image_size'][5].checked = false
|
2707
2550
|
end
|
2708
2551
|
}
|
2709
2552
|
}
|
@@ -2714,18 +2557,6 @@ class Wordpress
|
|
2714
2557
|
@data['image_size'][2].checked = false
|
2715
2558
|
@data['image_size'][3].checked = false
|
2716
2559
|
@data['image_size'][0].checked = false
|
2717
|
-
@data['image_size'][5].checked = false
|
2718
|
-
end
|
2719
|
-
}
|
2720
|
-
}
|
2721
|
-
@data['image_size'][5] = checkbox('원본 px'){
|
2722
|
-
on_toggled{
|
2723
|
-
if @data['image_size'][5].checked?
|
2724
|
-
@data['image_size'][1].checked = false
|
2725
|
-
@data['image_size'][2].checked = false
|
2726
|
-
@data['image_size'][3].checked = false
|
2727
|
-
@data['image_size'][0].checked = false
|
2728
|
-
@data['image_size'][4].checked = false
|
2729
2560
|
end
|
2730
2561
|
}
|
2731
2562
|
}
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wp_posting_duo
|
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
|