Compress an image with customizable settings. Note: For best results, use client-side compression via the web interface.
curl -X POST \
-F "image=@photo.jpg" \
-F "quality=70" \
-F "format=webp" \
-F "resize=false" \
YOUR_WORKER_URL/api/compress \
-o compressed.webp
const formData = new FormData();
formData.append('image', fileInput.files[0]);
formData.append('quality', '70');
formData.append('format', 'webp');
formData.append('resize', 'false');
const response = await fetch('/api/compress', {
method: 'POST',
body: formData
});
const blob = await response.blob();
// Create download or display compressed image
Parameters:
image - File (required) - Image file to compress
quality - Number (1-100) - Compression quality (default: 80)
format - String - Output format: auto, jpeg, png, webp
resize - Boolean - Enable image resizing (default: false)
maxWidth - Number - Maximum width if resize enabled
maxHeight - Number - Maximum height if resize enabled