{"uid":"cap_yp5o5Z0dHpmNgshmyRdO_","slug":"x402-image-tools-compress-99b855d8","name":"x402 Image Tools – Compress","description":"Make an image smaller in bytes: re-encode it (mozjpeg for JPEG, palette quantization for PNG) with metadata removed, optionally scaled down to a maximum width or converted, and report how much was saved.","url":"https://image.kagurazaka.dev/v1/compress?utm_source=zero.xyz","method":"POST","headers":{},"bodySchema":{"type":"object","properties":{"url":{"type":"string","description":"https URL of a JPEG, PNG, WebP, AVIF, GIF, TIFF or SVG image (up to 20 MB, 40 megapixels)"},"format":{"enum":["webp","avif","png","jpeg","gif","tiff"],"type":"string","description":"output format (default: the input's)"},"inline":{"type":"boolean","description":"also return the image as a data URL when it is at most 1 MB"},"quality":{"type":"integer","description":"1-100 (default 75)"},"max_width":{"type":"integer","description":"scale down to at most this width"}}},"responseSchema":{"type":"json","example":{"url":"https://dn8i8p8knpn68.cloudfront.net/results/images/3f1c2b9e.webp?Expires=...","bytes":48213,"width":800,"format":"webp","height":600,"expires_in":3600,"input_bytes":912345,"saved_percent":62.4}},"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.002","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"probe","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.002/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.002","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.002","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_xyhhat0DKruWdew8NsZNz","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.002","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Re-encodes a JPEG, PNG, or other image to reduce file size using mozjpeg/palette quantization, optionally scaling it down or converting format, and reports bytes saved.","exampleAgentPrompt":"Can you compress this image for me — https://example.com/photo.jpg — convert it to WebP at quality 75 and scale it down to a max width of 1200 pixels, then tell me how much space was saved?","exampleUseCases":[{"title":"Blog post image optimization","prompt":"I need to compress this hero image before I publish my blog post — https://myblog.com/uploads/hero.png — convert it to WebP at quality 80 and cap the width at 1400 pixels so it loads faster."},{"title":"E-commerce product photo slimming","prompt":"Can you shrink this product photo at https://shop.example.com/images/sneaker.jpg down to JPEG at quality 70, no wider than 800 pixels, and tell me the percentage of bytes saved?"},{"title":"Mobile app asset optimization","prompt":"This app icon at https://cdn.myapp.io/assets/icon_large.png is way too big — please re-encode it as PNG at quality 85, max 512 pixels wide, strip the metadata, and return it as a data URL if it ends up under 1 MB."}],"resultDescription":"A JSON object containing a CDN URL to the compressed image (valid for ~1 hour), the output file size in bytes, original file size in bytes, percentage saved, output dimensions (width × height), and format. Optionally includes the image as a data URL if inline was requested and the result is ≤1 MB.","failureModes":["Image URL is unreachable or returns a non-200 response — service cannot fetch the source image","Image exceeds 20 MB or 40 megapixel limit — request rejected","Unsupported input format — only JPEG, PNG, WebP, AVIF, GIF, TIFF, SVG accepted","Quality value out of 1-100 range — validation error","Compressed result URL expires after 3600 seconds — subsequent access returns 403/404","Network timeout fetching large source image"],"whenToPreferThis":"Choose this endpoint when you need to reduce an image's byte size for bandwidth, storage, or page-load reasons — especially when you want a byte-savings report alongside the result. It is preferable to a generic format-conversion endpoint when compression metrics (saved_percent, input_bytes vs output_bytes) matter, or when mozjpeg/palette quantization quality is desired. Use it over a resize endpoint when byte reduction is the primary goal and resizing is secondary.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-10-29T12:37:14.142Z","isFirstParty":false,"canonicalSlug":"x402-image-tools-compress-99b855d8"}