Image Format Converter
Automatically convert uploaded images to WebP/AVIF, optimize quality, and manage formats in Strapi. Bulk convert, persistent settings, easy setup
Strapi Image Format Converter Plugin
A powerful Strapi plugin for automatic image format conversion to modern formats like WebP and AVIF. Optimize your images for better performance and smaller file sizes.
Features
- 🚀 Automatic conversion on file upload
- 📦 Bulk conversion of existing files
- 🎛️ Quality control for WebP and AVIF formats
- 🔧 Flexible format selection (JPEG, PNG, GIF → WebP, AVIF)
- 💾 Persistent settings (saved between restarts)
- 🗑️ Automatic cleanup when original files are deleted
- 📱 Admin panel integration with user-friendly interface
- ⚡ Performance optimized with Sharp library
Installation
npm install strapi-plugin-imgfmtconv
Or install from GitHub:
npm install github:A-mi13/imgfmtconv
Configuration
The plugin comes with a default config/settings.json
file included in the repository. You can edit this file to set up your preferred options before starting Strapi.
Available Settings
Setting | Type | Default | Description |
---|---|---|---|
enabled | boolean | true | Enable/disable the plugin |
autoConvert | boolean | true | Auto-convert on file upload |
qualityWebp | number | 80 | WebP quality (0-100) |
qualityAvif | number | 70 | AVIF quality (0-100) |
formatsToConvert | array | ['jpeg', 'png', 'jpg', 'gif'] | Source formats to convert |
convertTo | array | ['webp', 'avif'] | Target formats |
Example Configuration
The default file looks like this:
1{
2 "enabled": true,
3 "autoConvert": true,
4 "qualityWebp": 80,
5 "qualityAvif": 50,
6 "formatsToConvert": ["jpeg", "png"],
7 "convertTo": ["webp", "avif"]
8}
You can edit config/settings.json
directly or via the admin panel.
Usage
Admin Panel
- Navigate to Content Manager → Image Format Converter in your Strapi admin panel
- Configure your settings
- Use the bulk conversion feature to convert existing images
API Endpoints
Get Settings
1GET /api/imgfmtconv/settings
Update Settings
1PUT /api/imgfmtconv/settings
2Content-Type: application/json
3
4{
5 "enabled": true,
6 "autoConvert": true,
7 "qualityWebp": 85,
8 "qualityAvif": 75,
9 "formatsToConvert": ["jpeg", "png"],
10 "convertTo": ["webp"]
11}
Reset to Defaults
1POST /api/imgfmtconv/settings/reset
Reload Settings from File
1POST /api/imgfmtconv/settings/reload
Bulk Convert Existing Images
1POST /api/imgfmtconv/bulk-convert
How It Works
- Upload Detection: When a file is uploaded to Strapi, the plugin checks if it matches the configured source formats
- Conversion: Using Sharp library, the image is converted to the specified target formats
- Storage: Converted files are saved alongside the original with appropriate extensions
- Cleanup: When the original file is deleted, converted versions are automatically removed
Performance Benefits
- WebP: 25-35% smaller than JPEG at equivalent quality
- AVIF: 50% smaller than JPEG at equivalent quality
- Automatic format selection: Modern browsers automatically choose the best format
- Fallback support: Original formats are preserved for older browsers
Browser Support
Format | Chrome | Firefox | Safari | Edge |
---|---|---|---|---|
WebP | 23+ | 65+ | 14+ | 18+ |
AVIF | 85+ | 93+ | 16.4+ | 85+ |
Requirements
- Node.js >= 18.0.0
- Strapi >= 5.0.0
- Sharp library (automatically installed)
Development
# Clone the repository
git clone https://github.com/A-mi13/imgfmtconv.git
# Install dependencies
npm install
# Link to your Strapi project
npm link
cd /path/to/your/strapi/project
npm link strapi-plugin-imgfmtconv
Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
- 🐛 Report a bug
- 💡 Request a feature
- 📧 Contact: GitHub Issues
Changelog
v1.0.0
- Initial release
- WebP and AVIF conversion support
- Admin panel integration
- Bulk conversion feature
- Persistent settings
Install now
npm install strapi-plugin-imgfmtconv
Create your own plugin
Check out the available plugin resources that will help you to develop your plugin or provider and get it listed on the marketplace.