mcpcn-office-powerpoint-mcp-server 2.1.1__py3-none-any.whl → 2.1.2__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.
- {mcpcn_office_powerpoint_mcp_server-2.1.1.dist-info → mcpcn_office_powerpoint_mcp_server-2.1.2.dist-info}/METADATA +82 -30
- mcpcn_office_powerpoint_mcp_server-2.1.2.dist-info/RECORD +25 -0
- {mcpcn_office_powerpoint_mcp_server-2.1.1.dist-info → mcpcn_office_powerpoint_mcp_server-2.1.2.dist-info}/WHEEL +1 -1
- {mcpcn_office_powerpoint_mcp_server-2.1.1.dist-info → mcpcn_office_powerpoint_mcp_server-2.1.2.dist-info}/licenses/LICENSE +20 -20
- ppt_mcp_server.py +474 -474
- slide_layout_templates.json +3689 -3689
- tools/__init__.py +27 -27
- tools/chart_tools.py +81 -81
- tools/connector_tools.py +90 -90
- tools/content_tools.py +966 -778
- tools/hyperlink_tools.py +137 -137
- tools/master_tools.py +113 -113
- tools/presentation_tools.py +211 -211
- tools/professional_tools.py +289 -289
- tools/structural_tools.py +372 -372
- tools/template_tools.py +520 -520
- tools/transition_tools.py +74 -74
- utils/__init__.py +69 -68
- utils/content_utils.py +633 -578
- utils/core_utils.py +54 -54
- utils/design_utils.py +688 -688
- utils/presentation_utils.py +216 -216
- utils/template_utils.py +1142 -1142
- utils/validation_utils.py +322 -322
- mcpcn_office_powerpoint_mcp_server-2.1.1.dist-info/RECORD +0 -25
- {mcpcn_office_powerpoint_mcp_server-2.1.1.dist-info → mcpcn_office_powerpoint_mcp_server-2.1.2.dist-info}/entry_points.txt +0 -0
tools/professional_tools.py
CHANGED
|
@@ -1,290 +1,290 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Professional design tools for PowerPoint MCP Server.
|
|
3
|
-
Handles themes, effects, fonts, and advanced formatting.
|
|
4
|
-
"""
|
|
5
|
-
from typing import Dict, List, Optional, Any
|
|
6
|
-
from mcp.server.fastmcp import FastMCP
|
|
7
|
-
import utils as ppt_utils
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
def register_professional_tools(app: FastMCP, presentations: Dict, get_current_presentation_id):
|
|
11
|
-
"""Register professional design tools with the FastMCP app"""
|
|
12
|
-
|
|
13
|
-
@app.tool()
|
|
14
|
-
def apply_professional_design(
|
|
15
|
-
operation: str, # "professional_slide", "theme", "enhance", "get_schemes"
|
|
16
|
-
slide_index: Optional[int] = None,
|
|
17
|
-
slide_type: str = "title_content",
|
|
18
|
-
color_scheme: str = "modern_blue",
|
|
19
|
-
title: Optional[str] = None,
|
|
20
|
-
content: Optional[List[str]] = None,
|
|
21
|
-
apply_to_existing: bool = True,
|
|
22
|
-
enhance_title: bool = True,
|
|
23
|
-
enhance_content: bool = True,
|
|
24
|
-
enhance_shapes: bool = True,
|
|
25
|
-
enhance_charts: bool = True,
|
|
26
|
-
presentation_id: Optional[str] = None
|
|
27
|
-
) -> Dict:
|
|
28
|
-
"""Unified professional design tool for themes, slides, and visual enhancements.
|
|
29
|
-
This applies professional styling and themes rather than structural layout changes."""
|
|
30
|
-
pres_id = presentation_id if presentation_id is not None else get_current_presentation_id()
|
|
31
|
-
|
|
32
|
-
if operation == "get_schemes":
|
|
33
|
-
# Return available color schemes
|
|
34
|
-
return ppt_utils.get_color_schemes()
|
|
35
|
-
|
|
36
|
-
if pres_id is None or pres_id not in presentations:
|
|
37
|
-
return {
|
|
38
|
-
"error": "No presentation is currently loaded or the specified ID is invalid"
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
pres = presentations[pres_id]
|
|
42
|
-
|
|
43
|
-
try:
|
|
44
|
-
if operation == "professional_slide":
|
|
45
|
-
# Add professional slide with advanced styling
|
|
46
|
-
if slide_index is not None and (slide_index < 0 or slide_index >= len(pres.slides)):
|
|
47
|
-
return {
|
|
48
|
-
"error": f"Invalid slide index: {slide_index}. Available slides: 0-{len(pres.slides) - 1}"
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
result = ppt_utils.add_professional_slide(
|
|
52
|
-
pres,
|
|
53
|
-
slide_type=slide_type,
|
|
54
|
-
color_scheme=color_scheme,
|
|
55
|
-
title=title,
|
|
56
|
-
content=content
|
|
57
|
-
)
|
|
58
|
-
|
|
59
|
-
return {
|
|
60
|
-
"message": f"Added professional {slide_type} slide",
|
|
61
|
-
"slide_index": len(pres.slides) - 1,
|
|
62
|
-
"color_scheme": color_scheme,
|
|
63
|
-
"slide_type": slide_type
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
elif operation == "theme":
|
|
67
|
-
# Apply professional theme
|
|
68
|
-
ppt_utils.apply_professional_theme(
|
|
69
|
-
pres,
|
|
70
|
-
color_scheme=color_scheme,
|
|
71
|
-
apply_to_existing=apply_to_existing
|
|
72
|
-
)
|
|
73
|
-
|
|
74
|
-
return {
|
|
75
|
-
"message": f"Applied {color_scheme} theme to presentation",
|
|
76
|
-
"color_scheme": color_scheme,
|
|
77
|
-
"applied_to_existing": apply_to_existing
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
elif operation == "enhance":
|
|
81
|
-
# Enhance existing slide
|
|
82
|
-
if slide_index is None:
|
|
83
|
-
return {
|
|
84
|
-
"error": "slide_index is required for enhance operation"
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
if slide_index < 0 or slide_index >= len(pres.slides):
|
|
88
|
-
return {
|
|
89
|
-
"error": f"Invalid slide index: {slide_index}. Available slides: 0-{len(pres.slides) - 1}"
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
slide = pres.slides[slide_index]
|
|
93
|
-
result = ppt_utils.enhance_existing_slide(
|
|
94
|
-
slide,
|
|
95
|
-
color_scheme=color_scheme,
|
|
96
|
-
enhance_title=enhance_title,
|
|
97
|
-
enhance_content=enhance_content,
|
|
98
|
-
enhance_shapes=enhance_shapes,
|
|
99
|
-
enhance_charts=enhance_charts
|
|
100
|
-
)
|
|
101
|
-
|
|
102
|
-
return {
|
|
103
|
-
"message": f"Enhanced slide {slide_index} with {color_scheme} scheme",
|
|
104
|
-
"slide_index": slide_index,
|
|
105
|
-
"color_scheme": color_scheme,
|
|
106
|
-
"enhancements_applied": result.get("enhancements_applied", [])
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
else:
|
|
110
|
-
return {
|
|
111
|
-
"error": f"Invalid operation: {operation}. Must be 'slide', 'theme', 'enhance', or 'get_schemes'"
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
except Exception as e:
|
|
115
|
-
return {
|
|
116
|
-
"error": f"Failed to apply professional design: {str(e)}"
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
@app.tool()
|
|
120
|
-
def apply_picture_effects(
|
|
121
|
-
slide_index: int,
|
|
122
|
-
shape_index: int,
|
|
123
|
-
effects: Dict[str, Dict], # {"shadow": {"blur_radius": 4.0, ...}, "glow": {...}}
|
|
124
|
-
presentation_id: Optional[str] = None
|
|
125
|
-
) -> Dict:
|
|
126
|
-
"""Apply multiple picture effects in combination."""
|
|
127
|
-
pres_id = presentation_id if presentation_id is not None else get_current_presentation_id()
|
|
128
|
-
|
|
129
|
-
if pres_id is None or pres_id not in presentations:
|
|
130
|
-
return {
|
|
131
|
-
"error": "No presentation is currently loaded or the specified ID is invalid"
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
pres = presentations[pres_id]
|
|
135
|
-
|
|
136
|
-
if slide_index < 0 or slide_index >= len(pres.slides):
|
|
137
|
-
return {
|
|
138
|
-
"error": f"Invalid slide index: {slide_index}. Available slides: 0-{len(pres.slides) - 1}"
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
slide = pres.slides[slide_index]
|
|
142
|
-
|
|
143
|
-
if shape_index < 0 or shape_index >= len(slide.shapes):
|
|
144
|
-
return {
|
|
145
|
-
"error": f"Invalid shape index: {shape_index}. Available shapes: 0-{len(slide.shapes) - 1}"
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
shape = slide.shapes[shape_index]
|
|
149
|
-
|
|
150
|
-
try:
|
|
151
|
-
applied_effects = []
|
|
152
|
-
warnings = []
|
|
153
|
-
|
|
154
|
-
# Apply each effect
|
|
155
|
-
for effect_type, effect_params in effects.items():
|
|
156
|
-
try:
|
|
157
|
-
if effect_type == "shadow":
|
|
158
|
-
ppt_utils.apply_picture_shadow(
|
|
159
|
-
shape,
|
|
160
|
-
shadow_type=effect_params.get("shadow_type", "outer"),
|
|
161
|
-
blur_radius=effect_params.get("blur_radius", 4.0),
|
|
162
|
-
distance=effect_params.get("distance", 3.0),
|
|
163
|
-
direction=effect_params.get("direction", 315.0),
|
|
164
|
-
color=effect_params.get("color", [0, 0, 0]),
|
|
165
|
-
transparency=effect_params.get("transparency", 0.6)
|
|
166
|
-
)
|
|
167
|
-
applied_effects.append("shadow")
|
|
168
|
-
|
|
169
|
-
elif effect_type == "reflection":
|
|
170
|
-
ppt_utils.apply_picture_reflection(
|
|
171
|
-
shape,
|
|
172
|
-
size=effect_params.get("size", 0.5),
|
|
173
|
-
transparency=effect_params.get("transparency", 0.5),
|
|
174
|
-
distance=effect_params.get("distance", 0.0),
|
|
175
|
-
blur=effect_params.get("blur", 4.0)
|
|
176
|
-
)
|
|
177
|
-
applied_effects.append("reflection")
|
|
178
|
-
|
|
179
|
-
elif effect_type == "glow":
|
|
180
|
-
ppt_utils.apply_picture_glow(
|
|
181
|
-
shape,
|
|
182
|
-
size=effect_params.get("size", 5.0),
|
|
183
|
-
color=effect_params.get("color", [0, 176, 240]),
|
|
184
|
-
transparency=effect_params.get("transparency", 0.4)
|
|
185
|
-
)
|
|
186
|
-
applied_effects.append("glow")
|
|
187
|
-
|
|
188
|
-
elif effect_type == "soft_edges":
|
|
189
|
-
ppt_utils.apply_picture_soft_edges(
|
|
190
|
-
shape,
|
|
191
|
-
radius=effect_params.get("radius", 2.5)
|
|
192
|
-
)
|
|
193
|
-
applied_effects.append("soft_edges")
|
|
194
|
-
|
|
195
|
-
elif effect_type == "rotation":
|
|
196
|
-
ppt_utils.apply_picture_rotation(
|
|
197
|
-
shape,
|
|
198
|
-
rotation=effect_params.get("rotation", 0.0)
|
|
199
|
-
)
|
|
200
|
-
applied_effects.append("rotation")
|
|
201
|
-
|
|
202
|
-
elif effect_type == "transparency":
|
|
203
|
-
ppt_utils.apply_picture_transparency(
|
|
204
|
-
shape,
|
|
205
|
-
transparency=effect_params.get("transparency", 0.0)
|
|
206
|
-
)
|
|
207
|
-
applied_effects.append("transparency")
|
|
208
|
-
|
|
209
|
-
elif effect_type == "bevel":
|
|
210
|
-
ppt_utils.apply_picture_bevel(
|
|
211
|
-
shape,
|
|
212
|
-
bevel_type=effect_params.get("bevel_type", "circle"),
|
|
213
|
-
width=effect_params.get("width", 6.0),
|
|
214
|
-
height=effect_params.get("height", 6.0)
|
|
215
|
-
)
|
|
216
|
-
applied_effects.append("bevel")
|
|
217
|
-
|
|
218
|
-
elif effect_type == "filter":
|
|
219
|
-
ppt_utils.apply_picture_filter(
|
|
220
|
-
shape,
|
|
221
|
-
filter_type=effect_params.get("filter_type", "none"),
|
|
222
|
-
intensity=effect_params.get("intensity", 0.5)
|
|
223
|
-
)
|
|
224
|
-
applied_effects.append("filter")
|
|
225
|
-
|
|
226
|
-
else:
|
|
227
|
-
warnings.append(f"Unknown effect type: {effect_type}")
|
|
228
|
-
|
|
229
|
-
except Exception as e:
|
|
230
|
-
warnings.append(f"Failed to apply {effect_type} effect: {str(e)}")
|
|
231
|
-
|
|
232
|
-
result = {
|
|
233
|
-
"message": f"Applied {len(applied_effects)} effects to shape {shape_index} on slide {slide_index}",
|
|
234
|
-
"applied_effects": applied_effects
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
if warnings:
|
|
238
|
-
result["warnings"] = warnings
|
|
239
|
-
|
|
240
|
-
return result
|
|
241
|
-
|
|
242
|
-
except Exception as e:
|
|
243
|
-
return {
|
|
244
|
-
"error": f"Failed to apply picture effects: {str(e)}"
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
@app.tool()
|
|
248
|
-
def manage_fonts(
|
|
249
|
-
operation: str, # "analyze", "optimize", "recommend"
|
|
250
|
-
font_path: str,
|
|
251
|
-
output_path: Optional[str] = None,
|
|
252
|
-
presentation_type: str = "business",
|
|
253
|
-
text_content: Optional[str] = None
|
|
254
|
-
) -> Dict:
|
|
255
|
-
"""Unified font management tool for analysis, optimization, and recommendations."""
|
|
256
|
-
try:
|
|
257
|
-
if operation == "analyze":
|
|
258
|
-
# Analyze font file
|
|
259
|
-
return ppt_utils.analyze_font_file(font_path)
|
|
260
|
-
|
|
261
|
-
elif operation == "optimize":
|
|
262
|
-
# Optimize font file
|
|
263
|
-
optimized_path = ppt_utils.optimize_font_for_presentation(
|
|
264
|
-
font_path,
|
|
265
|
-
output_path=output_path,
|
|
266
|
-
text_content=text_content
|
|
267
|
-
)
|
|
268
|
-
|
|
269
|
-
return {
|
|
270
|
-
"message": f"Optimized font: {font_path}",
|
|
271
|
-
"original_path": font_path,
|
|
272
|
-
"optimized_path": optimized_path
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
elif operation == "recommend":
|
|
276
|
-
# Get font recommendations
|
|
277
|
-
return ppt_utils.get_font_recommendations(
|
|
278
|
-
font_path,
|
|
279
|
-
presentation_type=presentation_type
|
|
280
|
-
)
|
|
281
|
-
|
|
282
|
-
else:
|
|
283
|
-
return {
|
|
284
|
-
"error": f"Invalid operation: {operation}. Must be 'analyze', 'optimize', or 'recommend'"
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
except Exception as e:
|
|
288
|
-
return {
|
|
289
|
-
"error": f"Failed to {operation} font: {str(e)}"
|
|
1
|
+
"""
|
|
2
|
+
Professional design tools for PowerPoint MCP Server.
|
|
3
|
+
Handles themes, effects, fonts, and advanced formatting.
|
|
4
|
+
"""
|
|
5
|
+
from typing import Dict, List, Optional, Any
|
|
6
|
+
from mcp.server.fastmcp import FastMCP
|
|
7
|
+
import utils as ppt_utils
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def register_professional_tools(app: FastMCP, presentations: Dict, get_current_presentation_id):
|
|
11
|
+
"""Register professional design tools with the FastMCP app"""
|
|
12
|
+
|
|
13
|
+
@app.tool()
|
|
14
|
+
def apply_professional_design(
|
|
15
|
+
operation: str, # "professional_slide", "theme", "enhance", "get_schemes"
|
|
16
|
+
slide_index: Optional[int] = None,
|
|
17
|
+
slide_type: str = "title_content",
|
|
18
|
+
color_scheme: str = "modern_blue",
|
|
19
|
+
title: Optional[str] = None,
|
|
20
|
+
content: Optional[List[str]] = None,
|
|
21
|
+
apply_to_existing: bool = True,
|
|
22
|
+
enhance_title: bool = True,
|
|
23
|
+
enhance_content: bool = True,
|
|
24
|
+
enhance_shapes: bool = True,
|
|
25
|
+
enhance_charts: bool = True,
|
|
26
|
+
presentation_id: Optional[str] = None
|
|
27
|
+
) -> Dict:
|
|
28
|
+
"""Unified professional design tool for themes, slides, and visual enhancements.
|
|
29
|
+
This applies professional styling and themes rather than structural layout changes."""
|
|
30
|
+
pres_id = presentation_id if presentation_id is not None else get_current_presentation_id()
|
|
31
|
+
|
|
32
|
+
if operation == "get_schemes":
|
|
33
|
+
# Return available color schemes
|
|
34
|
+
return ppt_utils.get_color_schemes()
|
|
35
|
+
|
|
36
|
+
if pres_id is None or pres_id not in presentations:
|
|
37
|
+
return {
|
|
38
|
+
"error": "No presentation is currently loaded or the specified ID is invalid"
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
pres = presentations[pres_id]
|
|
42
|
+
|
|
43
|
+
try:
|
|
44
|
+
if operation == "professional_slide":
|
|
45
|
+
# Add professional slide with advanced styling
|
|
46
|
+
if slide_index is not None and (slide_index < 0 or slide_index >= len(pres.slides)):
|
|
47
|
+
return {
|
|
48
|
+
"error": f"Invalid slide index: {slide_index}. Available slides: 0-{len(pres.slides) - 1}"
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
result = ppt_utils.add_professional_slide(
|
|
52
|
+
pres,
|
|
53
|
+
slide_type=slide_type,
|
|
54
|
+
color_scheme=color_scheme,
|
|
55
|
+
title=title,
|
|
56
|
+
content=content
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
return {
|
|
60
|
+
"message": f"Added professional {slide_type} slide",
|
|
61
|
+
"slide_index": len(pres.slides) - 1,
|
|
62
|
+
"color_scheme": color_scheme,
|
|
63
|
+
"slide_type": slide_type
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
elif operation == "theme":
|
|
67
|
+
# Apply professional theme
|
|
68
|
+
ppt_utils.apply_professional_theme(
|
|
69
|
+
pres,
|
|
70
|
+
color_scheme=color_scheme,
|
|
71
|
+
apply_to_existing=apply_to_existing
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
return {
|
|
75
|
+
"message": f"Applied {color_scheme} theme to presentation",
|
|
76
|
+
"color_scheme": color_scheme,
|
|
77
|
+
"applied_to_existing": apply_to_existing
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
elif operation == "enhance":
|
|
81
|
+
# Enhance existing slide
|
|
82
|
+
if slide_index is None:
|
|
83
|
+
return {
|
|
84
|
+
"error": "slide_index is required for enhance operation"
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if slide_index < 0 or slide_index >= len(pres.slides):
|
|
88
|
+
return {
|
|
89
|
+
"error": f"Invalid slide index: {slide_index}. Available slides: 0-{len(pres.slides) - 1}"
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
slide = pres.slides[slide_index]
|
|
93
|
+
result = ppt_utils.enhance_existing_slide(
|
|
94
|
+
slide,
|
|
95
|
+
color_scheme=color_scheme,
|
|
96
|
+
enhance_title=enhance_title,
|
|
97
|
+
enhance_content=enhance_content,
|
|
98
|
+
enhance_shapes=enhance_shapes,
|
|
99
|
+
enhance_charts=enhance_charts
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
return {
|
|
103
|
+
"message": f"Enhanced slide {slide_index} with {color_scheme} scheme",
|
|
104
|
+
"slide_index": slide_index,
|
|
105
|
+
"color_scheme": color_scheme,
|
|
106
|
+
"enhancements_applied": result.get("enhancements_applied", [])
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
else:
|
|
110
|
+
return {
|
|
111
|
+
"error": f"Invalid operation: {operation}. Must be 'slide', 'theme', 'enhance', or 'get_schemes'"
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
except Exception as e:
|
|
115
|
+
return {
|
|
116
|
+
"error": f"Failed to apply professional design: {str(e)}"
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
@app.tool()
|
|
120
|
+
def apply_picture_effects(
|
|
121
|
+
slide_index: int,
|
|
122
|
+
shape_index: int,
|
|
123
|
+
effects: Dict[str, Dict], # {"shadow": {"blur_radius": 4.0, ...}, "glow": {...}}
|
|
124
|
+
presentation_id: Optional[str] = None
|
|
125
|
+
) -> Dict:
|
|
126
|
+
"""Apply multiple picture effects in combination."""
|
|
127
|
+
pres_id = presentation_id if presentation_id is not None else get_current_presentation_id()
|
|
128
|
+
|
|
129
|
+
if pres_id is None or pres_id not in presentations:
|
|
130
|
+
return {
|
|
131
|
+
"error": "No presentation is currently loaded or the specified ID is invalid"
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
pres = presentations[pres_id]
|
|
135
|
+
|
|
136
|
+
if slide_index < 0 or slide_index >= len(pres.slides):
|
|
137
|
+
return {
|
|
138
|
+
"error": f"Invalid slide index: {slide_index}. Available slides: 0-{len(pres.slides) - 1}"
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
slide = pres.slides[slide_index]
|
|
142
|
+
|
|
143
|
+
if shape_index < 0 or shape_index >= len(slide.shapes):
|
|
144
|
+
return {
|
|
145
|
+
"error": f"Invalid shape index: {shape_index}. Available shapes: 0-{len(slide.shapes) - 1}"
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
shape = slide.shapes[shape_index]
|
|
149
|
+
|
|
150
|
+
try:
|
|
151
|
+
applied_effects = []
|
|
152
|
+
warnings = []
|
|
153
|
+
|
|
154
|
+
# Apply each effect
|
|
155
|
+
for effect_type, effect_params in effects.items():
|
|
156
|
+
try:
|
|
157
|
+
if effect_type == "shadow":
|
|
158
|
+
ppt_utils.apply_picture_shadow(
|
|
159
|
+
shape,
|
|
160
|
+
shadow_type=effect_params.get("shadow_type", "outer"),
|
|
161
|
+
blur_radius=effect_params.get("blur_radius", 4.0),
|
|
162
|
+
distance=effect_params.get("distance", 3.0),
|
|
163
|
+
direction=effect_params.get("direction", 315.0),
|
|
164
|
+
color=effect_params.get("color", [0, 0, 0]),
|
|
165
|
+
transparency=effect_params.get("transparency", 0.6)
|
|
166
|
+
)
|
|
167
|
+
applied_effects.append("shadow")
|
|
168
|
+
|
|
169
|
+
elif effect_type == "reflection":
|
|
170
|
+
ppt_utils.apply_picture_reflection(
|
|
171
|
+
shape,
|
|
172
|
+
size=effect_params.get("size", 0.5),
|
|
173
|
+
transparency=effect_params.get("transparency", 0.5),
|
|
174
|
+
distance=effect_params.get("distance", 0.0),
|
|
175
|
+
blur=effect_params.get("blur", 4.0)
|
|
176
|
+
)
|
|
177
|
+
applied_effects.append("reflection")
|
|
178
|
+
|
|
179
|
+
elif effect_type == "glow":
|
|
180
|
+
ppt_utils.apply_picture_glow(
|
|
181
|
+
shape,
|
|
182
|
+
size=effect_params.get("size", 5.0),
|
|
183
|
+
color=effect_params.get("color", [0, 176, 240]),
|
|
184
|
+
transparency=effect_params.get("transparency", 0.4)
|
|
185
|
+
)
|
|
186
|
+
applied_effects.append("glow")
|
|
187
|
+
|
|
188
|
+
elif effect_type == "soft_edges":
|
|
189
|
+
ppt_utils.apply_picture_soft_edges(
|
|
190
|
+
shape,
|
|
191
|
+
radius=effect_params.get("radius", 2.5)
|
|
192
|
+
)
|
|
193
|
+
applied_effects.append("soft_edges")
|
|
194
|
+
|
|
195
|
+
elif effect_type == "rotation":
|
|
196
|
+
ppt_utils.apply_picture_rotation(
|
|
197
|
+
shape,
|
|
198
|
+
rotation=effect_params.get("rotation", 0.0)
|
|
199
|
+
)
|
|
200
|
+
applied_effects.append("rotation")
|
|
201
|
+
|
|
202
|
+
elif effect_type == "transparency":
|
|
203
|
+
ppt_utils.apply_picture_transparency(
|
|
204
|
+
shape,
|
|
205
|
+
transparency=effect_params.get("transparency", 0.0)
|
|
206
|
+
)
|
|
207
|
+
applied_effects.append("transparency")
|
|
208
|
+
|
|
209
|
+
elif effect_type == "bevel":
|
|
210
|
+
ppt_utils.apply_picture_bevel(
|
|
211
|
+
shape,
|
|
212
|
+
bevel_type=effect_params.get("bevel_type", "circle"),
|
|
213
|
+
width=effect_params.get("width", 6.0),
|
|
214
|
+
height=effect_params.get("height", 6.0)
|
|
215
|
+
)
|
|
216
|
+
applied_effects.append("bevel")
|
|
217
|
+
|
|
218
|
+
elif effect_type == "filter":
|
|
219
|
+
ppt_utils.apply_picture_filter(
|
|
220
|
+
shape,
|
|
221
|
+
filter_type=effect_params.get("filter_type", "none"),
|
|
222
|
+
intensity=effect_params.get("intensity", 0.5)
|
|
223
|
+
)
|
|
224
|
+
applied_effects.append("filter")
|
|
225
|
+
|
|
226
|
+
else:
|
|
227
|
+
warnings.append(f"Unknown effect type: {effect_type}")
|
|
228
|
+
|
|
229
|
+
except Exception as e:
|
|
230
|
+
warnings.append(f"Failed to apply {effect_type} effect: {str(e)}")
|
|
231
|
+
|
|
232
|
+
result = {
|
|
233
|
+
"message": f"Applied {len(applied_effects)} effects to shape {shape_index} on slide {slide_index}",
|
|
234
|
+
"applied_effects": applied_effects
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
if warnings:
|
|
238
|
+
result["warnings"] = warnings
|
|
239
|
+
|
|
240
|
+
return result
|
|
241
|
+
|
|
242
|
+
except Exception as e:
|
|
243
|
+
return {
|
|
244
|
+
"error": f"Failed to apply picture effects: {str(e)}"
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
@app.tool()
|
|
248
|
+
def manage_fonts(
|
|
249
|
+
operation: str, # "analyze", "optimize", "recommend"
|
|
250
|
+
font_path: str,
|
|
251
|
+
output_path: Optional[str] = None,
|
|
252
|
+
presentation_type: str = "business",
|
|
253
|
+
text_content: Optional[str] = None
|
|
254
|
+
) -> Dict:
|
|
255
|
+
"""Unified font management tool for analysis, optimization, and recommendations."""
|
|
256
|
+
try:
|
|
257
|
+
if operation == "analyze":
|
|
258
|
+
# Analyze font file
|
|
259
|
+
return ppt_utils.analyze_font_file(font_path)
|
|
260
|
+
|
|
261
|
+
elif operation == "optimize":
|
|
262
|
+
# Optimize font file
|
|
263
|
+
optimized_path = ppt_utils.optimize_font_for_presentation(
|
|
264
|
+
font_path,
|
|
265
|
+
output_path=output_path,
|
|
266
|
+
text_content=text_content
|
|
267
|
+
)
|
|
268
|
+
|
|
269
|
+
return {
|
|
270
|
+
"message": f"Optimized font: {font_path}",
|
|
271
|
+
"original_path": font_path,
|
|
272
|
+
"optimized_path": optimized_path
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
elif operation == "recommend":
|
|
276
|
+
# Get font recommendations
|
|
277
|
+
return ppt_utils.get_font_recommendations(
|
|
278
|
+
font_path,
|
|
279
|
+
presentation_type=presentation_type
|
|
280
|
+
)
|
|
281
|
+
|
|
282
|
+
else:
|
|
283
|
+
return {
|
|
284
|
+
"error": f"Invalid operation: {operation}. Must be 'analyze', 'optimize', or 'recommend'"
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
except Exception as e:
|
|
288
|
+
return {
|
|
289
|
+
"error": f"Failed to {operation} font: {str(e)}"
|
|
290
290
|
}
|