Strapi plugin logo for Image Format Converter

Image Format Converter

Automatically convert uploaded images to WebP/AVIF, optimize quality, and manage formats in Strapi. Bulk convert, persistent settings, easy setup

thumbnail for Image Format Converter

Strapi Image Format Converter Plugin

npm version License: MIT Strapi

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

SettingTypeDefaultDescription
enabledbooleantrueEnable/disable the plugin
autoConvertbooleantrueAuto-convert on file upload
qualityWebpnumber80WebP quality (0-100)
qualityAvifnumber70AVIF quality (0-100)
formatsToConvertarray['jpeg', 'png', 'jpg', 'gif']Source formats to convert
convertToarray['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

  1. Navigate to Content ManagerImage Format Converter in your Strapi admin panel
  2. Configure your settings
  3. 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

  1. Upload Detection: When a file is uploaded to Strapi, the plugin checks if it matches the configured source formats
  2. Conversion: Using Sharp library, the image is converted to the specified target formats
  3. Storage: Converted files are saved alongside the original with appropriate extensions
  4. 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

FormatChromeFirefoxSafariEdge
WebP23+65+14+18+
AVIF85+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

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

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

STATS

No GitHub star yetNot downloaded this week

Last updated

90 days ago

Strapi Version

5.0.0 and above

Author

github profile image for A-mi13
A-mi13

Useful links

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.