Optimize Image
optimize_imageOptimize images with smart compression, resize, upscale, format conversion, and AI SEO metadata generation. Accepts local files or URLs.
Instructions
Optimize an image: smart lossy compression (typically 60-80% size reduction), optional resize/upscale/format conversion, and AI-generated SEO metadata. Accepts absolute local file paths or remote URLs. In remote/API mode, only remote URLs are supported. Supported input formats: JPG, PNG, WebP, AVIF, GIF, SVG, ICO, HEIC, TIFF, BMP (max 50 MB). Supported output formats: JPG, PNG, WebP, AVIF, GIF, SVG, ICO. Each call costs 3 credits + 1 if SEO tags enabled. Animated GIFs are processed frame-by-frame (each frame optimized individually). Cost = frames × per-frame operations. Use confirm_gif_cost: true after reviewing the cost warning. Free tier: 20 credits/day, no signup. Log in with the login tool for more credits. Use status tool to check remaining credits before batch processing.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| input | Yes | Absolute local file path or remote URL of the image to optimize. Note: in remote/API mode, only remote URLs are supported (no local file paths). Supported inputs: JPG, PNG, WebP, AVIF, GIF (animated supported), HEIC, TIFF, BMP (max 50 MB). GlassyPic supports high-quality conversion between any input and output format. | |
| output_path | No | Where to save. Accepts a file path (/tmp/out.webp) or directory ending in / (/tmp/images/). If omitted: saves next to original, named with SEO slug when SEO is enabled or .tinified suffix otherwise. URLs save to current working directory. | |
| output_format | No | Output format. Defaults to 'original' (keep input format). Animated GIFs stay animated when output is 'gif'; converting to other formats preserves only the first frame. SVG output from raster input uses vector tracing. ICO output generates a favicon set (16, 24, 32, 48, 256px) unless a specific size is given. | |
| gif_frame_limit | No | Maximum frames to process for animated GIFs (1-100, default 100). Reduces cost by sampling fewer frames while preserving animation. | |
| output_width_px | No | Target width in pixels. Set only width for proportional resize. Set both width and height for exact output dimensions (see output_resize_behavior). | |
| confirm_gif_cost | No | Set to true to proceed with animated GIF processing after seeing cost warning. Required for animated GIFs to prevent unexpected credit consumption. | |
| output_height_px | No | Target height in pixels. Set only height for proportional resize. Set both width and height for exact output dimensions (see output_resize_behavior). | |
| _gif_temp_file_id | No | Internal: temp file ID from a previous GIF cost warning. Skips re-upload. | |
| output_seo_tag_gen | No | Generate SEO metadata (alt text, keywords, filename) and rename output file to SEO slug. Costs 1 extra credit. Default: true. | |
| output_upscale_factor | No | AI upscale factor: 2 (2×) or 4 (4×). Uses Real-ESRGAN for high-quality upscaling. | |
| output_file_size_limit | No | Target maximum output file size in bytes. The server will attempt to meet this limit through additional compression. Not guaranteed. | |
| output_resize_behavior | No | When both width and height are set and aspect ratio differs: 'pad' adds white padding (default), 'crop' smart-crops to fill exact dimensions |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| output_path | Yes | Absolute path where the optimized file was saved | |
| seo_alt_text | Yes | AI-generated image alt text for accessibility and SEO | |
| seo_filename | Yes | AI-generated SEO filename slug without extension | |
| seo_keywords | Yes | AI-generated keywords describing the image | |
| output_format | Yes | Output format: jpg, png, webp, avif, or gif | |
| output_width_px | Yes | Width of the output image in pixels | |
| output_height_px | Yes | Height of the output image in pixels | |
| compression_ratio | Yes | Output-to-input size ratio, e.g. 0.35 means 65% smaller | |
| output_size_bytes | Yes | File size of the optimized image in bytes |