Skip to main content
Glama

get_screenshot_info

Extract dimensions and basic metadata from webpage screenshots to support layout analysis and reconstruction.

Instructions

Get basic information about a screenshot image, including its dimensions (width and height in pixels).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
screenshot_pathYesAbsolute path to the screenshot image file

Implementation Reference

  • The handler logic for the 'get_screenshot_info' tool within the call_tool function. It validates the screenshot path, calls the helper to get dimensions, formats the result as JSON, and returns it as TextContent.
    elif name == "get_screenshot_info":
        screenshot_path = arguments["screenshot_path"]
    
        if not Path(screenshot_path).exists():
            return [TextContent(
                type="text",
                text=json.dumps({"error": f"Screenshot not found: {screenshot_path}"})
            )]
    
        width, height = get_screenshot_dimensions(screenshot_path)
    
        result = {
            "path": screenshot_path,
            "width": width,
            "height": height,
        }
    
        return [TextContent(type="text", text=json.dumps(result, indent=2))]
  • The tool schema definition including name, description, and inputSchema for 'get_screenshot_info', provided in the list_tools handler.
    Tool(
        name="get_screenshot_info",
        description=(
            "Get basic information about a screenshot image, including its "
            "dimensions (width and height in pixels)."
        ),
        inputSchema={
            "type": "object",
            "properties": {
                "screenshot_path": {
                    "type": "string",
                    "description": "Absolute path to the screenshot image file",
                },
            },
            "required": ["screenshot_path"],
        },
    ),
  • Registration of the 'get_screenshot_info' tool (among others) in the @server.list_tools() handler, returning a list of Tool objects.
    return [
        Tool(
            name="find_assets_in_screenshot",
            description=(
                "Find known image assets within a screenshot. Uses template matching "
                "to locate each asset and return its position (x, y, width, height). "
                "Useful for determining where specific images appear in a webpage screenshot."
            ),
            inputSchema={
                "type": "object",
                "properties": {
                    "screenshot_path": {
                        "type": "string",
                        "description": "Absolute path to the screenshot image file",
                    },
                    "asset_paths": {
                        "type": "array",
                        "items": {"type": "string"},
                        "description": "List of absolute paths to asset images to find",
                    },
                    "threshold": {
                        "type": "number",
                        "description": "Match confidence threshold (0-1). Default 0.8",
                        "default": 0.8,
                    },
                },
                "required": ["screenshot_path", "asset_paths"],
            },
        ),
        Tool(
            name="analyze_layout",
            description=(
                "Analyze the layout of assets in a screenshot. Finds all assets, "
                "identifies the center/hero element, calculates relative positions "
                "(angle and distance from center), and detects the layout pattern "
                "(radial, grid, or freeform). Returns structured data for rebuilding "
                "the layout with semantic CSS."
            ),
            inputSchema={
                "type": "object",
                "properties": {
                    "screenshot_path": {
                        "type": "string",
                        "description": "Absolute path to the screenshot image file",
                    },
                    "asset_paths": {
                        "type": "array",
                        "items": {"type": "string"},
                        "description": "List of absolute paths to asset images to find",
                    },
                    "threshold": {
                        "type": "number",
                        "description": "Match confidence threshold (0-1). Default 0.8",
                        "default": 0.8,
                    },
                },
                "required": ["screenshot_path", "asset_paths"],
            },
        ),
        Tool(
            name="get_screenshot_info",
            description=(
                "Get basic information about a screenshot image, including its "
                "dimensions (width and height in pixels)."
            ),
            inputSchema={
                "type": "object",
                "properties": {
                    "screenshot_path": {
                        "type": "string",
                        "description": "Absolute path to the screenshot image file",
                    },
                },
                "required": ["screenshot_path"],
            },
        ),
    ]
  • Core helper function that implements the screenshot dimension extraction by loading the image with load_image and reading its shape.
    def get_screenshot_dimensions(screenshot_path: str) -> tuple[int, int]:
        """Get the dimensions of a screenshot."""
        img = load_image(screenshot_path)
        h, w = img.shape[:2]
        return (w, h)

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/katlis/layout-detector-mcp'

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