Skip to main content
Glama

set_aspect_ratio

Configure the aspect ratio for image generation and editing sessions to ensure consistent dimensions across creations. Specify ratios like 16:9 or 1:1 before processing images.

Instructions

Set the aspect ratio for subsequent image generation and editing in this session. Must be called before generating/editing images if a specific ratio is desired.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
aspect_ratioYesThe aspect ratio to use for image generation/editing
conversation_idNoSession ID to apply this setting to (default: 'default')

Implementation Reference

  • The implementation of the set_aspect_ratio tool handler, which validates the aspect ratio and updates the context for a given conversation.
    case "set_aspect_ratio": {
      const { aspect_ratio, conversation_id = "default" } = args as any;
    
      // Validate aspect ratio
      if (!VALID_ASPECT_RATIOS.includes(aspect_ratio as AspectRatio)) {
        return {
          content: [{
            type: "text",
            text: `Invalid aspect ratio: ${aspect_ratio}. Valid: ${VALID_ASPECT_RATIOS.join(", ")}`,
          }],
          isError: true,
        };
      }
    
      const context = getOrCreateContext(conversation_id);
      context.aspectRatio = aspect_ratio as AspectRatio;
    
      return {
        content: [{
          type: "text",
          text: `✓ Aspect ratio set to ${aspect_ratio} for session: ${conversation_id}\nThis will apply to both image generation and editing.`,
        }],
      };
    }
  • src/index.ts:422-435 (registration)
    Registration of the set_aspect_ratio tool, including its description and input schema definition.
    name: "set_aspect_ratio",
    description: "Set the aspect ratio for subsequent image generation and editing in this session. Must be called before generating/editing images if a specific ratio is desired.",
    inputSchema: {
      type: "object",
      properties: {
        aspect_ratio: {
          type: "string",
          enum: [...VALID_ASPECT_RATIOS],
          description: "The aspect ratio to use for image generation/editing",
        },
        conversation_id: {
          type: "string",
          description: "Session ID to apply this setting to (default: 'default')",
        },

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/pistachiomatt/nanobanana-mcp'

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