{"uid":"cap__HByP_dWeAIRnCw5mAuT4","slug":"x402-image-tools-compress-773ccaff","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://7fg5bxb40m3f0v23.68r.lambda-web.us-east-1.on.aws/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_Mh9OX2wH2acM41RbMV2iu","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 or PNG image using mozjpeg/palette quantization, removes metadata, optionally scales or converts it, and returns a CDN URL with byte-savings stats.","exampleAgentPrompt":"Can you compress this product photo for me — https://example.com/product.jpg — convert it to WebP at quality 80, scale it down to a max width of 1200 pixels, and tell me how many bytes I saved?","exampleUseCases":[{"title":"Shrinking blog hero images","prompt":"I have a hero image at https://myblog.com/images/hero.png — can you compress it to WebP at quality 75 so it loads faster on my site? Show me how much space I save."},{"title":"E-commerce product photo optimization","prompt":"Please compress this product image — https://shop.example.com/imgs/shoes.jpg — keep it as JPEG at quality 85 and scale it down to at most 800 pixels wide. I want the byte savings report too."},{"title":"Mobile app asset preparation","prompt":"Optimize this app screenshot at https://cdn.myapp.io/screenshots/onboarding.png by converting it to AVIF at quality 70 and max width 600px — I need to know the final file size and how much was saved."}],"resultDescription":"A JSON object with a CDN URL to the compressed image (valid for 3600 seconds), the output file size in bytes, the input file size in bytes, percentage saved, output dimensions (width and height), and the output format. Optionally includes the image as a base64 data URL if it is under 1 MB and inline was requested.","failureModes":["Image URL unreachable or returns non-200 status — endpoint cannot fetch source image","Image exceeds 20 MB or 40 megapixels limit — request rejected","Unsupported format provided in the format enum — validation error","quality value outside 1–100 range — parameter error","Compressed result is not smaller than the original — savings may be 0% or negative","Payment not accepted or x402 auth failure — 402 response"],"whenToPreferThis":"Choose this endpoint when you need to reduce image file size for web delivery, bandwidth savings, or storage cost, and want detailed byte-savings reporting alongside a ready-to-use CDN URL. It is particularly well-suited for JPEG and PNG optimization (mozjpeg, palette quantization) and supports format conversion in the same call. Prefer it over a generic resize endpoint when compression ratio and metadata stripping are the primary goals, rather than dimension changes.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-10-29T12:35:47.208Z","isFirstParty":false,"canonicalSlug":"x402-image-tools-compress-773ccaff"}