Skip to main content
Glama
qiniu

Qiniu MCP Server

Official
by qiniu

image_scale_by_percent

Resize images stored in Qiniu Cloud Buckets by a specified percentage and retrieve the scaled image URL for direct access or viewing. Supports formats like JPEG, PNG, GIF, and more.

Instructions

Image scaling tool that resizes images based on a percentage 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
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.
percentYesScaling percentage, range [1,999]. For example: 90 means the image width and height are reduced to 90% of the original; 200 means the width and height are enlarged to 200% of the original.

Implementation Reference

  • The core handler function that implements the logic for scaling an image by a given percentage using Qiniu's imageMogr2 FOP. Validates inputs and constructs the processed object_url.
    def image_scale_by_percent( self, **kwargs ) -> list[types.TextContent | types.ImageContent | types.EmbeddedResource]: object_url = kwargs.get("object_url", "") percent = kwargs.get("percent", "") if object_url is None or len(object_url) == 0: return [types.TextContent(type="text", text="object_url is required")] percent_int = int(percent) if percent_int < 1 or percent_int > 999: return [ types.TextContent(type="text", text="percent must be between 1 and 999") ] func = f"imageMogr2/thumbnail/!{percent}p" 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, } ), ) ]
  • The tool metadata decorator defining the schema, name, description, and input validation for the image_scale_by_percent tool.
    @tools.tool_meta( types.Tool( name="image_scale_by_percent", description="""Image scaling tool that resizes images based on a percentage 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 }, "percent": { "type": "integer", "description": "Scaling percentage, range [1,999]. For example: 90 means the image width and height are reduced to 90% of the original; 200 means the width and height are enlarged to 200% of the original.", "minimum": 1, "maximum": 999 }, }, "required": ["object_url", "percent"], }, ) )
  • The registration function that instantiates the tool implementation class and registers the image_scale_by_percent handler (among others) with the tools system.
    def register_tools(cfg: config.Config, cli: MediaProcessingService): tool_impl = _ToolImpl(cfg, cli) 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, ] )

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