Skip to main content
Glama
qiniu

Qiniu MCP Server

Official
by qiniu

image_scale_by_size

Resize images proportionally by specifying width or height using Qiniu Cloud Bucket. Returns object_url for direct HTTP GET requests or browser viewing, supporting formats like jpeg, png, gif, and webp.

Instructions

Image scaling tool that resizes images based on a specified width or height and returns information about the scaled image. The information includes the object_url of the scaled image, which users can directly use for HTTP GET requests to retrieve the image content or open in a browser to view the file. The image must be stored in a Qiniu Cloud Bucket. Supported original image formats: psd, jpeg, png, gif, webp, tiff, bmp, avif, heic. Image width and height cannot exceed 30,000 pixels, and total pixels cannot exceed 150 million.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
heightNoSpecifies the height for image scaling. The image will be scaled to the specified height, and the width will be adjusted proportionally.
object_urlYesThe URL of the image. This can be a URL obtained via the GetObjectURL tool or a URL generated by other Fop tools. Length Constraints: Minimum length of 1.
widthNoSpecifies the width for image scaling. The image will be scaled to the specified width, and the height will be adjusted proportionally.

Implementation Reference

  • The handler function implementing the image_scale_by_size tool logic. It validates the object_url and constructs the Qiniu FOP URL using imageMogr2/thumbnail/{width}x{height} for scaling.
    def image_scale_by_size( self, **kwargs ) -> list[types.TextContent]: object_url = kwargs.get("object_url", "") width = kwargs.get("width", "") height = kwargs.get("height", "") if object_url is None or len(object_url) == 0: return [types.TextContent(type="text", text="object_url is required")] func = f"{width}x{height}" if len(func) == 1: return [ types.TextContent( type="text", text="At least one width or height must be set" ) ] func = f"imageMogr2/thumbnail/{func}" object_url = utils.url_add_processing_func(auth=self.auth, url=object_url, func=func) return [ types.TextContent( type="text", text=str( { "object_url": object_url, } ), ) ]
  • Input schema definition for the image_scale_by_size tool, specifying object_url as required, and optional width/height parameters.
    """, inputSchema={ "type": "object", "properties": { "object_url": { "type": "string", "description": _OBJECT_URL_DESC }, "width": { "type": "integer", "description": "Specifies the width for image scaling. The image will be scaled to the specified width, and the height will be adjusted proportionally.", "minimum": 1 }, "height": { "type": "integer", "description": "Specifies the height for image scaling. The image will be scaled to the specified height, and the width will be adjusted proportionally.", "minimum": 1 }, }, "required": ["object_url"] },
  • Registers the image_scale_by_size tool (along with others) using tools.auto_register_tools in the register_tools function.
    tools.auto_register_tools( [ tool_impl.image_scale_by_percent, tool_impl.image_scale_by_size, tool_impl.image_round_corner, tool_impl.image_info, ] )
  • The @tools.tool_meta decorator registers the tool metadata including name, description, and schema for image_scale_by_size.
    @tools.tool_meta( types.Tool( name="image_scale_by_size", description="""Image scaling tool that resizes images based on a specified width or height and returns information about the scaled image. The information includes the object_url of the scaled image, which users can directly use for HTTP GET requests to retrieve the image content or open in a browser to view the file. The image must be stored in a Qiniu Cloud Bucket. Supported original image formats: psd, jpeg, png, gif, webp, tiff, bmp, avif, heic. Image width and height cannot exceed 30,000 pixels, and total pixels cannot exceed 150 million. """, inputSchema={ "type": "object", "properties": { "object_url": { "type": "string", "description": _OBJECT_URL_DESC }, "width": { "type": "integer", "description": "Specifies the width for image scaling. The image will be scaled to the specified width, and the height will be adjusted proportionally.", "minimum": 1 }, "height": { "type": "integer", "description": "Specifies the height for image scaling. The image will be scaled to the specified height, and the width will be adjusted proportionally.", "minimum": 1 }, }, "required": ["object_url"] }, ) )

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/qiniu/qiniu-mcp-server'

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