Optimize Image
optimize_imageReduce image file size with smart lossy compression, resize or upscale, convert format, and generate AI SEO metadata. Works for local paths and remote 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. Credits: 3 to compress (always), +1 if width or height is set, +2 to upscale, +1 for SEO tags (on by default). A full pipeline is 7 credits. Upscale is charged whether you request it or the server adds it automatically — it does so whenever a resize target exceeds the source by more than 1.2x, so a resize-only call on a small image also costs 7. SVG or ICO output is a flat 1 credit, overriding everything above. Animated GIFs are billed per frame: (per-frame operations x frames) + 1 if tags, up to 601 credits at the 100-frame limit — confirm_gif_cost gates that path. GIFs are excluded from automatic upscaling. Guest (unregistered): 20 credits/day, no signup. Log in with the login tool for more credits — registered Free tier is 30/day. 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). Costs 1 credit. If the target exceeds the source by more than 1.2x, the server also adds an AI upscale for a further 2 credits. | |
| 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). Costs 1 credit. If the target exceeds the source by more than 1.2x, the server also adds an AI upscale for a further 2 credits. | |
| _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. Costs 2 credits. Note that upscaling also triggers automatically, without this parameter, whenever a resize target exceeds the source by more than 1.2x — the same 2 credits are charged either way. | |
| 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 |