thumbnail-maker 0.1.1__py3-none-any.whl → 0.1.3__py3-none-any.whl

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.

Potentially problematic release.


This version of thumbnail-maker might be problematic. Click here for more details.

thumbnail_maker/gui.py CHANGED
@@ -332,6 +332,11 @@ class ThumbnailGUI(QMainWindow):
332
332
  layout.addWidget(self.title_outline_check)
333
333
  layout.addWidget(QLabel('외곽선 두께:'))
334
334
  layout.addWidget(self.title_outline_thickness)
335
+
336
+ # 워드 랩
337
+ self.title_word_wrap = QCheckBox('단어 단위 줄바꿈')
338
+ self.title_word_wrap.stateChanged.connect(self.update_preview)
339
+ layout.addWidget(self.title_word_wrap)
335
340
 
336
341
  # 위치 (9 그리드)
337
342
  self.title_position = QComboBox()
@@ -442,9 +447,14 @@ class ThumbnailGUI(QMainWindow):
442
447
  self.subtitle_position.addItems(['tl', 'tc', 'tr', 'ml', 'mc', 'mr', 'bl', 'bc', 'br'])
443
448
  self.subtitle_position.setCurrentText('bl')
444
449
  self.subtitle_position.currentTextChanged.connect(self.update_preview)
450
+
451
+ # 워드 랩
452
+ self.subtitle_word_wrap = QCheckBox('단어 단위 줄바꿈')
453
+ self.subtitle_word_wrap.stateChanged.connect(self.update_preview)
445
454
 
446
455
  layout.addWidget(QLabel('위치:'))
447
456
  layout.addWidget(self.subtitle_position)
457
+ layout.addWidget(self.subtitle_word_wrap)
448
458
 
449
459
  layout.addStretch()
450
460
  widget.setLayout(layout)
@@ -581,7 +591,7 @@ class ThumbnailGUI(QMainWindow):
581
591
  'fontWeight': self.title_font_weight.currentText() or 'bold',
582
592
  'fontStyle': self.title_font_style.currentText() or 'normal',
583
593
  'lineHeight': 1.1,
584
- 'wordWrap': False,
594
+ 'wordWrap': self.title_word_wrap.isChecked(),
585
595
  'outline': {
586
596
  'thickness': self.title_outline_thickness.value(),
587
597
  'color': '#000000'
@@ -610,7 +620,7 @@ class ThumbnailGUI(QMainWindow):
610
620
  'fontWeight': self.subtitle_font_weight.currentText() or 'normal',
611
621
  'fontStyle': self.subtitle_font_style.currentText() or 'normal',
612
622
  'lineHeight': 1.1,
613
- 'wordWrap': False,
623
+ 'wordWrap': self.subtitle_word_wrap.isChecked(),
614
624
  'outline': None,
615
625
  'enabled': True
616
626
  })
@@ -247,6 +247,41 @@ class ThumbnailRenderer:
247
247
  def split_lines(text: str) -> List[str]:
248
248
  """텍스트를 줄 단위로 분리"""
249
249
  return text.split('\n')
250
+
251
+ @staticmethod
252
+ def wrap_line_by_words(
253
+ draw: ImageDraw.ImageDraw,
254
+ text: str,
255
+ font: ImageFont.FreeTypeFont,
256
+ max_width: int
257
+ ) -> List[str]:
258
+ """단어 단위로 한 줄을 주어진 최대 폭에 맞게 개행한다.
259
+
260
+ - 공백으로 단어를 나눈 뒤, 누적 폭이 넘어가면 이전까지를 한 줄로 확정한다.
261
+ - 단어 하나가 max_width보다 커도 단어 단위 래핑 원칙상 강제 분할은 하지 않는다.
262
+ - 입력이 빈 문자열이면 ['']을 반환한다.
263
+ """
264
+ if text is None or text == '':
265
+ return ['']
266
+
267
+ words = text.split(' ')
268
+ lines: List[str] = []
269
+ current = ''
270
+
271
+ for word in words:
272
+ candidate = word if current == '' else current + ' ' + word
273
+ bbox = draw.textbbox((0, 0), candidate, font=font)
274
+ candidate_width = bbox[2] - bbox[0]
275
+ if candidate_width > max_width and current != '':
276
+ lines.append(current)
277
+ current = word
278
+ else:
279
+ current = candidate
280
+
281
+ if current != '':
282
+ lines.append(current)
283
+
284
+ return lines if lines else ['']
250
285
 
251
286
  @staticmethod
252
287
  def load_font(font_path: str, size: int, weight: str = 'normal', style: str = 'normal') -> ImageFont.FreeTypeFont:
@@ -484,8 +519,26 @@ class ThumbnailRenderer:
484
519
  except Exception:
485
520
  font = ImageFont.load_default()
486
521
 
487
- # 줄 분리
488
- lines = ThumbnailRenderer.split_lines(content)
522
+ # 줄 분리 및 단어 단위 줄바꿈 처리
523
+ initial_lines = ThumbnailRenderer.split_lines(content)
524
+ effective_max_width = width - 2 * ThumbnailRenderer.MARGIN
525
+
526
+ if wordWrap:
527
+ processed_lines: List[str] = []
528
+ for init_line in initial_lines:
529
+ if init_line == '':
530
+ processed_lines.append('')
531
+ else:
532
+ wrapped = ThumbnailRenderer.wrap_line_by_words(
533
+ draw=draw,
534
+ text=init_line,
535
+ font=font,
536
+ max_width=effective_max_width,
537
+ )
538
+ processed_lines.extend(wrapped)
539
+ lines = processed_lines
540
+ else:
541
+ lines = initial_lines
489
542
 
490
543
  # 라인 높이 계산
491
544
  lh = int(fontSize * lineHeight)
@@ -0,0 +1,154 @@
1
+ Metadata-Version: 2.4
2
+ Name: thumbnail-maker
3
+ Version: 0.1.3
4
+ Summary: 썸네일 생성 도구 - Pillow와 PySide6 기반
5
+ Requires-Python: >=3.10
6
+ Requires-Dist: fonttools>=4.47.0
7
+ Requires-Dist: pillow>=10.0.0
8
+ Requires-Dist: pyside6>=6.10.0
9
+ Requires-Dist: requests>=2.31.0
10
+ Requires-Dist: uv-easy>=0.2.5
11
+ Description-Content-Type: text/markdown
12
+
13
+ # 썸네일 생성기 (Python)
14
+
15
+ JavaScript 기반 썸네일 생성기를 Python으로 변환한 프로젝트입니다.
16
+
17
+ ## 주요 변경사항
18
+
19
+ - **Pillow**: 이미지 생성 라이브러리로 사용
20
+ - **PySide6**: GUI 프레임워크로 사용
21
+ - **Python**: 모든 코드를 Python으로 변환
22
+
23
+ ## 설치 및 실행
24
+
25
+ uv로 의존성 설치:
26
+
27
+ ```bash
28
+ uv sync
29
+ ```
30
+
31
+ 단일 엔트리포인트(서브명령 방식):
32
+
33
+ ```bash
34
+ uv run thumbnail_maker --help
35
+ ```
36
+
37
+ ### 1) GUI 실행 (추천)
38
+
39
+ ```bash
40
+ uv run thumbnail_maker gui
41
+ ```
42
+
43
+ 기능:
44
+ - 제목/부제목 폰트: 웹폰트 URL 또는 로컬 폰트 파일 선택
45
+ - DSL 보기/저장: 현재 설정을 `thumbnail.json`으로 저장
46
+ - 패키지 저장(.thl): `thumbnail.json` + `fonts/`(TTF/OTF) 묶음으로 저장
47
+
48
+ ### 2) DSL 렌더 (generate-thumbnail)
49
+
50
+ ```bash
51
+ uv run thumbnail_maker generate-thumbnail thumbnail.json -o out.png
52
+ ```
53
+
54
+ 또는 패키지(.thl)로부터 렌더:
55
+
56
+ ```bash
57
+ uv run thumbnail_maker generate-thumbnail my_pack.thl -o out.png
58
+ ```
59
+
60
+ ### 3) 간편 렌더 (genthumb)
61
+
62
+ ```bash
63
+ # 제목/부제목 덮어쓰기 (리터럴 \n 또는 실제 줄바꿈 지원)
64
+ uv run thumbnail_maker genthumb -o out.png \
65
+ --title "이것이 블로그다.\n파워블로그를 위한" \
66
+ --subtitle "블로그하는\n\n 법 꿀팁모음" \
67
+ my_thumb.json
68
+
69
+ # 패키지(.thl) 입력도 동일하게 지원
70
+ uv run thumbnail_maker genthumb -o out.png my_pack.thl
71
+ ```
72
+
73
+ ## 주요 파일/구성
74
+
75
+ ```
76
+ thumbnail_maker/
77
+ ├── thumbnail_maker/
78
+ │ ├── __main__.py # 단일 엔트리포인트 (gui, generate-thumbnail, genthumb)
79
+ │ ├── gui.py # PySide6 GUI
80
+ │ ├── cli.py # CLI 로직(패키지 해제 포함)
81
+ │ └── renderer.py # Pillow 기반 렌더러 (폰트 다운로드/변환/폴백)
82
+ ├── thumbnail.json # DSL 예제
83
+ └── fonts/ # 변환/다운로드된 TTF/OTF 저장 위치
84
+ ```
85
+
86
+ ## DSL 파일 형식
87
+
88
+ ```json
89
+ {
90
+ "Thumbnail": {
91
+ "Resolution": {
92
+ "type": "preset",
93
+ "value": "16:9"
94
+ },
95
+ "Background": {
96
+ "type": "solid",
97
+ "color": "#a3e635"
98
+ },
99
+ "Texts": [
100
+ {
101
+ "type": "title",
102
+ "content": "제목 텍스트",
103
+ "gridPosition": "tl",
104
+ "font": {
105
+ "name": "SBAggroB",
106
+ "faces": [...]
107
+ },
108
+ "fontSize": 48,
109
+ "color": "#4ade80",
110
+ "outline": {
111
+ "thickness": 7,
112
+ "color": "#000000"
113
+ },
114
+ "enabled": true
115
+ }
116
+ ]
117
+ }
118
+ }
119
+ ```
120
+
121
+ ## 해상도 설정
122
+
123
+ ### Preset 모드
124
+ ```json
125
+ {
126
+ "type": "preset",
127
+ "value": "16:9" // "16:9", "9:16", "4:3", "1:1"
128
+ }
129
+ ```
130
+
131
+ ### Fixed Ratio 모드
132
+ ```json
133
+ {
134
+ "type": "fixedRatio",
135
+ "ratioValue": "16:9",
136
+ "width": 480 // 또는 height 지정
137
+ }
138
+ ```
139
+
140
+ ### Custom 모드
141
+ ```json
142
+ {
143
+ "type": "custom",
144
+ "width": 480,
145
+ "height": 270
146
+ }
147
+ ```
148
+
149
+ ## 기타
150
+
151
+ - JavaScript 버전 파일들은 레거시로 유지됩니다.
152
+ - DSL/패키지(.thl) 모두 지원합니다.
153
+ - 폰트는 자동 다운로드/변환되어 `fonts/`(프로젝트/패키지 내부)에 저장·사용됩니다.
154
+
@@ -0,0 +1,10 @@
1
+ thumbnail_maker/__init__.py,sha256=ybcxf-LnaQ2LA3lf9oiDPuQ0ggIoeX2D0U07TF-dJGk,144
2
+ thumbnail_maker/__main__.py,sha256=1zceMBWaASmxXhSGHIXIXqt1A4MFxUxskRdOMq7zcEg,2955
3
+ thumbnail_maker/cli.py,sha256=bH1bSjhPuvGNkHe3kF3stNQ7ujBU07b1dyPspoMWBgY,5256
4
+ thumbnail_maker/cli_new.py,sha256=NRRm68d7uM3EH3g4bP9A7sSOsmpae-4IPOrbWRfqhZc,981
5
+ thumbnail_maker/gui.py,sha256=RrycEPlCPMdIA3m6Mwo4p9f0fRG0xOUgIZFPV9v9M7M,35758
6
+ thumbnail_maker/renderer.py,sha256=wNmooCpdZ45_susu9zIChlalho-ubSI0q3iXrkJQRLE,25142
7
+ thumbnail_maker-0.1.3.dist-info/METADATA,sha256=qGBcHDNiJLRTx3-Krb0-GrdDK3S-R9V8cu4nlpwBLnY,3446
8
+ thumbnail_maker-0.1.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
9
+ thumbnail_maker-0.1.3.dist-info/entry_points.txt,sha256=rqhlHR3PzlOlRmCL745NshLfST4yxtGNubqAghAJ5hA,66
10
+ thumbnail_maker-0.1.3.dist-info/RECORD,,
@@ -1,158 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: thumbnail-maker
3
- Version: 0.1.1
4
- Summary: 썸네일 생성 도구 - Pillow와 PySide6 기반
5
- Requires-Python: >=3.10
6
- Requires-Dist: fonttools>=4.47.0
7
- Requires-Dist: pillow>=10.0.0
8
- Requires-Dist: pyside6>=6.10.0
9
- Requires-Dist: requests>=2.31.0
10
- Requires-Dist: uv-easy>=0.2.5
11
- Description-Content-Type: text/markdown
12
-
13
- # 썸네일 생성기 (Python)
14
-
15
- JavaScript 기반 썸네일 생성기를 Python으로 변환한 프로젝트입니다.
16
-
17
- ## 주요 변경사항
18
-
19
- - **Pillow**: 이미지 생성 라이브러리로 사용
20
- - **PySide6**: GUI 프레임워크로 사용
21
- - **Python**: 모든 코드를 Python으로 변환
22
-
23
- ## 설치 방법
24
-
25
- ```bash
26
- pip install -r requirements.txt
27
- ```
28
-
29
- ## 사용 방법
30
-
31
- uv를 사용하여 설치:
32
-
33
- ```bash
34
- uv sync
35
- ```
36
-
37
- 또는 직접 실행:
38
-
39
- ```bash
40
- uv run python -m thumbnail_maker
41
- ```
42
-
43
- ### 1. GUI 사용 (추천)
44
-
45
- ```bash
46
- uv run thumbnail-gui
47
- ```
48
-
49
- PySide6 기반 GUI에서 썸네일을 생성할 수 있습니다.
50
-
51
- ### 2. CLI 사용
52
-
53
- #### 기본 사용
54
- ```bash
55
- uv run generate-thumbnail
56
- ```
57
-
58
- #### DSL 파일 지정
59
- ```bash
60
- uv run generate-thumbnail mydsl.json -o output.png
61
- ```
62
-
63
- #### 간편 CLI (genthumb)
64
- ```bash
65
- # 기본
66
- uv run genthumb
67
-
68
- # 제목/부제목 덮어쓰기
69
- uv run genthumb --title "새 제목" --subtitle "새 부제목"
70
-
71
- # 배경 이미지 설정
72
- uv run genthumb --bgImg bg.png
73
-
74
- # 출력 파일 지정
75
- uv run genthumb -o result.png
76
- ```
77
-
78
- ## 파일 구조
79
-
80
- ```
81
- thumbnail_maker/
82
- ├── requirements.txt # Python 패키지 의존성
83
- ├── thumbnailRenderer.py # 핵심 렌더링 로직
84
- ├── generateThumbnail.py # 메인 생성 스크립트
85
- ├── genthumb.py # 간편 CLI 스크립트
86
- ├── main_gui.py # PySide6 GUI 애플리케이션
87
- └── thumbnail.json # DSL 예제 파일
88
- ```
89
-
90
- ## DSL 파일 형식
91
-
92
- ```json
93
- {
94
- "Thumbnail": {
95
- "Resolution": {
96
- "type": "preset",
97
- "value": "16:9"
98
- },
99
- "Background": {
100
- "type": "solid",
101
- "color": "#a3e635"
102
- },
103
- "Texts": [
104
- {
105
- "type": "title",
106
- "content": "제목 텍스트",
107
- "gridPosition": "tl",
108
- "font": {
109
- "name": "SBAggroB",
110
- "faces": [...]
111
- },
112
- "fontSize": 48,
113
- "color": "#4ade80",
114
- "outline": {
115
- "thickness": 7,
116
- "color": "#000000"
117
- },
118
- "enabled": true
119
- }
120
- ]
121
- }
122
- }
123
- ```
124
-
125
- ## 해상도 설정
126
-
127
- ### Preset 모드
128
- ```json
129
- {
130
- "type": "preset",
131
- "value": "16:9" // "16:9", "9:16", "4:3", "1:1"
132
- }
133
- ```
134
-
135
- ### Fixed Ratio 모드
136
- ```json
137
- {
138
- "type": "fixedRatio",
139
- "ratioValue": "16:9",
140
- "width": 480 // 또는 height 지정
141
- }
142
- ```
143
-
144
- ### Custom 모드
145
- ```json
146
- {
147
- "type": "custom",
148
- "width": 480,
149
- "height": 270
150
- }
151
- ```
152
-
153
- ## 기타
154
-
155
- - JavaScript 버전의 파일들은 유지됩니다.
156
- - 기존 DSL 파일과 호환됩니다.
157
- - 폰트는 `fonts/` 디렉토리에 저장됩니다.
158
-
@@ -1,10 +0,0 @@
1
- thumbnail_maker/__init__.py,sha256=ybcxf-LnaQ2LA3lf9oiDPuQ0ggIoeX2D0U07TF-dJGk,144
2
- thumbnail_maker/__main__.py,sha256=1zceMBWaASmxXhSGHIXIXqt1A4MFxUxskRdOMq7zcEg,2955
3
- thumbnail_maker/cli.py,sha256=bH1bSjhPuvGNkHe3kF3stNQ7ujBU07b1dyPspoMWBgY,5256
4
- thumbnail_maker/cli_new.py,sha256=NRRm68d7uM3EH3g4bP9A7sSOsmpae-4IPOrbWRfqhZc,981
5
- thumbnail_maker/gui.py,sha256=JW_FvoZZi0iHvXVclKMVRrPLLHeBp6HjiOK8ZvWKoE4,35266
6
- thumbnail_maker/renderer.py,sha256=0EMtoVeaaRE6a3gbhd53tYt1lOD44pqO-8Xw9khNKvk,23022
7
- thumbnail_maker-0.1.1.dist-info/METADATA,sha256=KC1uqXKdLIu5MxSPfV3FKgfe4LrHUtdFvKAIt6aqFLU,2912
8
- thumbnail_maker-0.1.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
9
- thumbnail_maker-0.1.1.dist-info/entry_points.txt,sha256=rqhlHR3PzlOlRmCL745NshLfST4yxtGNubqAghAJ5hA,66
10
- thumbnail_maker-0.1.1.dist-info/RECORD,,