Skip to main content
Glama

apply_sepia

Apply a vintage sepia tone filter to images. Input an image file path or base64 data to transform it into a warm, classic brownish hue using the Image Processing MCP Server.

Instructions

应用复古棕褐色滤镜

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
image_sourceYes图片源,可以是文件路径或base64编码的图片数据

Implementation Reference

  • Core handler function implementing the sepia filter by applying a color transformation matrix to each pixel of the image.
    async def apply_sepia(image_data: str) -> list[TextContent]: """ 应用复古棕褐色滤镜 Args: image_data: 图片数据(base64编码) Returns: 应用滤镜后的图片数据 """ try: # 验证参数 if not image_data: raise ValidationError("图片数据不能为空") # 加载图片 image = processor.load_image(image_data) # 转换为RGB模式 if image.mode != 'RGB': image = image.convert('RGB') # 应用棕褐色滤镜 pixels = image.load() width, height = image.size for y in range(height): for x in range(width): r, g, b = pixels[x, y] # 棕褐色变换公式 tr = int(0.393 * r + 0.769 * g + 0.189 * b) tg = int(0.349 * r + 0.686 * g + 0.168 * b) tb = int(0.272 * r + 0.534 * g + 0.131 * b) # 确保值在0-255范围内 tr = min(255, tr) tg = min(255, tg) tb = min(255, tb) pixels[x, y] = (tr, tg, tb) # 输出处理后的图片 output_info = processor.output_image(image, "sepia") result = { "success": True, "message": "复古棕褐色滤镜应用成功", "data": { **output_info, "filter_type": "sepia", "size": image.size } } return [TextContent(type="text", text=json.dumps(result, ensure_ascii=False))] except ValidationError as e: error_result = { "success": False, "error": f"参数验证失败: {str(e)}" } return [TextContent(type="text", text=json.dumps(error_result, ensure_ascii=False))] except Exception as e: error_result = { "success": False, "error": f"复古棕褐色滤镜应用失败: {str(e)}" } return [TextContent(type="text", text=json.dumps(error_result, ensure_ascii=False))]
  • main.py:354-367 (registration)
    MCP tool registration decorator (@mcp.tool()) and wrapper function that delegates to the core handler in tools/filters.py.
    @mcp.tool() def apply_sepia( image_source: Annotated[str, Field(description="图片源,可以是文件路径或base64编码的图片数据")] ) -> str: """应用复古棕褐色滤镜""" try: result = safe_run_async(filters_apply_sepia(image_source)) return result[0].text except Exception as e: return json.dumps({ "success": False, "error": f"应用复古滤镜失败: {str(e)}" }, ensure_ascii=False, indent=2)
  • Tool schema definition including name, description, and input schema for the apply_sepia tool.
    Tool( name="apply_sepia", description="应用复古棕褐色滤镜", inputSchema={ "type": "object", "properties": { "image_data": { "type": "string", "description": "图片数据(base64编码)" } }, "required": ["image_data"] } ),

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/duke0317/ps-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server