Image Format Converter logo

Image Format Converter

By Alexander

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

Latest version

v1.0.1

released July 24, 2025

npm install strapi-plugin-imgfmtconv

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:

{
  "enabled": true,
  "autoConvert": true,
  "qualityWebp": 80,
  "qualityAvif": 50,
  "formatsToConvert": ["jpeg", "png"],
  "convertTo": ["webp", "avif"]
}

You can edit config/settings.json directly or via the admin panel.

Usage

Admin Panel

  1. Navigate to Content Manager → Image 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

GET /api/imgfmtconv/settings

Update Settings

PUT /api/imgfmtconv/settings
Content-Type: application/json

{
  "enabled": true,
  "autoConvert": true,
  "qualityWebp": 85,
  "qualityAvif": 75,
  "formatsToConvert": ["jpeg", "png"],
  "convertTo": ["webp"]
}

Reset to Defaults

POST /api/imgfmtconv/settings/reset

Reload Settings from File

POST /api/imgfmtconv/settings/reload

Bulk Convert Existing Images

POST /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

Submit your content

Share your work with the community and get it listed in the Strapi ecosystem for everyone to discover and use.

Submit
Submit your content