Format Conversion
Automatically convert images to more efficient formats.
PNG to JPEG
Convert PNG to JPEG when beneficial:
Try it live
Pick a sample or upload your own image
Vue component — live
PixuCompressor with real sample images
Click or drag image here to compress
Supports JPEG, PNG, WEBP, AVIF, PIXU
Or try a real sample
typescript
const result = await compress(pngFile, {
quality: 0.8,
convertToJPEG: true,
});Automatic Detection
Pixu automatically converts PNG to JPEG when:
- File size is larger than 500KB
- Image has no transparency
- JPEG would be more efficient
Manual Format Selection
Try it live
Pick a sample or upload your own image
Vue component — live
PixuCompressor with real sample images
Click or drag image here to compress
Supports JPEG, PNG, WEBP, AVIF, PIXU
Or try a real sample
typescript
const result = await compress(file, {
quality: 0.8,
format: 'image/webp',
});Format Options
Available formats:
image/jpegimage/pngimage/webpimage/avifauto- Automatically select best format
Example
typescript
import { compress } from '@pantanal/pixu';
async function optimizeFormat(file: File) {
const result = await compress(file, {
quality: 0.8,
convertToJPEG: true,
});
return result.file;
}
async function convertToWebP(file: File) {
const result = await compress(file, {
quality: 0.8,
format: 'image/webp',
});
return result.file;
}