MCPcopy Create free account
hub / github.com/ResearAI/AutoFigure / enhance

Method enhance

autofigure/enhancer.py:267–333  ·  view source on GitHub ↗

Enhance an image file using the configured provider. Args: input_path: Path to the input image (PNG) output_path: Path for the enhanced output (optional) enhancement_input: Enhancement prompt or code style: Art style for enhancement

(
        self,
        input_path: str,
        output_path: Optional[str] = None,
        enhancement_input: str = "",
        style: Optional[str] = None,
        input_type: str = "code2prompt",
    )

Source from the content-addressed store, hash-verified

265 self.config = config
266
267 def enhance(
268 self,
269 input_path: str,
270 output_path: Optional[str] = None,
271 enhancement_input: str = "",
272 style: Optional[str] = None,
273 input_type: str = "code2prompt",
274 ) -> Optional[str]:
275 """
276 Enhance an image file using the configured provider.
277
278 Args:
279 input_path: Path to the input image (PNG)
280 output_path: Path for the enhanced output (optional)
281 enhancement_input: Enhancement prompt or code
282 style: Art style for enhancement
283 input_type: 'none' | 'code' | 'code2prompt'
284 - 'none': Direct visual enhancement without code reference
285 - 'code': Use code as reference (svg_code mode)
286 - 'code2prompt': Use LLM-generated detailed prompt
287
288 Returns:
289 Path to the enhanced image, or None on failure
290 """
291 api_key = self.config.enhancement_api_key
292 if not api_key:
293 print("[ImageEnhancer] No enhancement API key configured, skipping enhancement")
294 return None
295
296 input_path = Path(input_path)
297 if not input_path.exists():
298 print(f"[ImageEnhancer] Input file not found: {input_path}")
299 return None
300
301 # Default output path
302 if output_path is None:
303 output_path = str(input_path.parent / f"{input_path.stem}_enhanced.png")
304
305 provider = self.config.enhancement_provider
306 model = self.config.enhancement_model
307 base_url = self.config.enhancement_base_url
308 art_style = style or self.config.art_style or ""
309
310 print(f"[ImageEnhancer] Provider: {provider}")
311 print(f"[ImageEnhancer] Model: {model}")
312 print(f"[ImageEnhancer] Style: {art_style or '(default)'}")
313 print(f"[ImageEnhancer] Input type: {input_type}")
314
315 # Route to provider-specific function
316 if provider == "openrouter":
317 return self._enhance_with_openrouter(
318 str(input_path), enhancement_input, output_path,
319 style=art_style, input_type=input_type,
320 api_key=api_key, base_url=base_url, model=model
321 )
322 elif provider == "gemini":
323 return self._enhance_with_gemini(
324 str(input_path), enhancement_input, output_path,

Callers 2

_run_enhancementFunction · 0.95
generateMethod · 0.80

Calls 3

_enhance_with_geminiMethod · 0.95
_enhance_with_bianxieMethod · 0.95

Tested by

no test coverage detected