=== MegaOptim Image Optimizer – Convert to WebP & AVIF, Compress Images Locally ===
Contributors: megaoptim, darkog
Tags: webp, avif, compress images, optimize images, image optimizer
Requires at least: 5.8
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 3.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Convert images to WebP and AVIF and compress them on your own server. No account, no API key, no image credits, and your images never leave your site.

== Description ==

MegaOptim optimizes the images of your WordPress site on your own server. It creates WebP and AVIF copies of your JPEG, PNG and GIF images, serves them to browsers that support them, and can compress the originals in place. Nothing is uploaded anywhere, and there are no monthly limits.

= What it does =

* **WebP and AVIF copies** of every image and thumbnail size, kept next to the original. A copy that would be larger than the original is skipped.
* **Delivery** through `<picture>` markup or Apache/LiteSpeed rewrite rules, with the original as the fallback for older browsers. A CDN URL can be set for the copies.
* **Compression in place** for JPEG and PNG, with three presets: Lossless, Balanced and Smaller files. Advanced settings hold separate WebP and AVIF quality, resizing of large uploads, metadata and the thumbnail sizes to process.
* **Backups and restore.** Originals are backed up before they are changed, and any image can be restored, one at a time or all at once.
* **Bulk optimization** of the whole Media Library with one button. It runs in the background, survives closing the page, and shows its progress on the Overview and in Activity.
* **New uploads** are optimized automatically.
* **Folders outside the Media Library**, such as theme or plugin image folders.
* **Compare** an original with its optimized version side by side.
* **WP-CLI:** `wp megaoptim optimize`, `restore`, `status` and `stats`.
* **Diagnostics** that show which image engines your server offers and what each one can do.

= How images are processed =

MegaOptim uses what your server already has: the GD or Imagick PHP extensions, and command-line encoders such as `cwebp`, `avifenc`, `jpegtran`, `pngquant`, `oxipng` or `gifsicle` when your host has them installed. The plugin itself contains no executables. AVIF needs GD or Imagick built with AVIF support, or `avifenc`. Tools → Server diagnostics shows what is available on your server.

= MegaOptim Pro =

[MegaOptim Pro](https://codeverve.com/product/megaoptim-pro/) is an optional add-on. It brings its own native engine for Linux (MozJPEG, libwebp, libavif, oxipng, pngquant, gifsicle), which compresses noticeably better than GD or Imagick and turns animated GIFs into animated WebP. Its smart quality picks the lowest quality for each image that still looks the same, measured with SSIMULACRA 2. Pro also optimizes media offloaded to S3-compatible storage with S3 Uploads or WP Offload Media, and adds parallel WP-CLI and network-wide tools for multisite. Images are still processed on your server.

= Source code =

The admin screens are a Vue application. Its source is included in the plugin's `admin` folder and is built with `bun install && bun run build`.

== Installation ==

1. Install and activate MegaOptim Image Optimizer.
2. Open Media → MegaOptim.
3. On Settings, pick a preset and the formats to create (WebP, AVIF or both). Tools → Server diagnostics shows what your server can do.
4. Optimize a few images on the Images screen and compare them with the originals.
5. Click Optimize library on the Overview to process everything else. New uploads are optimized automatically.

== Frequently Asked Questions ==

= Do I need an account or an API key? =
No. Since version 3.0, everything runs on your server and there is nothing to sign up for.

= I used MegaOptim with an API key. What happens when I update? =
The MegaOptim cloud service has been retired, and version 3.0 replaces it with local processing. Your settings, optimization history and backups are kept, and the stored API key is removed. Images that were waiting for the cloud are paused and listed, so you can review the new settings and resume them locally. Former paying customers receive MegaOptim Pro free of charge; watch your inbox.

= Is AVIF supported? =
Yes, when your server can encode AVIF: GD or Imagick built with AVIF support, or the `avifenc` tool. Tools → Server diagnostics shows whether it can. MegaOptim Pro includes its own AVIF encoder.

= Are my original images changed? =
WebP and AVIF copies are separate files; the original stays as it is. Compression does change the original file, so MegaOptim backs it up first (unless you turn backups off) and you can restore it at any time from the Images screen or with `wp megaoptim restore`.

= Is compression lossless? =
Only with the Lossless preset. Balanced and Smaller files reduce quality slightly in exchange for smaller files. Use Compare to check the result on a few images before optimizing the whole library.

= Why was a WebP or AVIF copy not created? =
MegaOptim skips a copy that would be larger than the original, which happens with images that are already well compressed. The Images screen marks these as "original smaller". Other reasons are listed in Activity.

= How are WebP and AVIF served to visitors? =
With `<picture>` markup (the default), which works on any server and with most caching plugins, or with rewrite rules for Apache and LiteSpeed, which keep your HTML unchanged. Browsers that do not support a format get the original.

= My images are stored on S3 or another cloud storage. =
The free plugin optimizes files that are on your server and skips offloaded files with an explanation. MegaOptim Pro optimizes media offloaded with S3 Uploads or WP Offload Media and uploads the WebP and AVIF copies with them.

= Does it work with WP-CLI? =
Yes. `wp megaoptim optimize --all` optimizes the library, `wp megaoptim optimize --folder=<path>` a folder, `wp megaoptim restore <id>` restores an image, and `wp megaoptim status` shows the queue.

= Does MegaOptim send my images anywhere? =
No. Images are processed on your server, and the free plugin does not contact any service.

== Screenshots ==

1. Overview: library coverage, space saved and one button to optimize the whole library.
2. Images: every image with its savings and formats, filterable by status and source.
3. Compare an original with its optimized version.
4. Settings: a quality preset, the formats to create and optimization of new uploads.
5. Advanced settings: WebP and AVIF quality, resizing and metadata.
6. Activity: background work as it happens.
7. Tools and diagnostics: restore everything, and see what your server can do.

== Upgrade Notice ==

= 3.0.0 =
MegaOptim now runs entirely on your server, and the cloud API has been retired. Settings, history and backups are kept. If you used an API key, images waiting for the cloud are paused for you to review and resume locally.

== Changelog ==

= 3.0.0 =
* All optimization now runs on your server. The cloud API, API keys and image credits are gone.
* A redesigned admin: Overview, Images, Settings, Activity and Tools, with one Optimize action for compression and WebP/AVIF.
* Settings presets (Lossless, Balanced, Smaller files) with separate WebP and AVIF quality.
* Better JPEG output with Imagick and GD: progressive encoding, optimized Huffman tables, and never a higher quality than the source.
* Originals are backed up before every change, for media and folder images, and restore no longer re-optimizes the restored file.
* Native encoders keep a photo's embedded color profile, so photos from cameras and editors no longer fall back to Imagick.
* A new background queue: atomic claims, two images at a time, and progress that continues when the page is closed.
* WebP and AVIF copies that would be larger than the original are recorded as such instead of being retried.
* Offloaded media is detected and skipped with an explanation instead of failing.
* WP-CLI: `wp megaoptim optimize`, `restore` and `status`.
* The plugin no longer contains executables; it uses GD, Imagick and tools installed on the server.
* Upgrades from cloud versions keep settings, history and backups, remove the stored API key and pause pending cloud work for review.

= 2.0.2 =
* File System view: Convert and Compress now work on folders and single files, with live progress.
* Fix: Convert no longer drops thumbnail siblings. Every thumbnail size now produces its own WebP and AVIF file.
* Fix: forced re-convert kept the freshly converted files instead of wiping them at the end of the run.
* Polished folder modal (mode-aware hero, force re-process toggle, cancel-during-run, per-file failure list).

= 2.0.0 =
* Complete refactor of the plugin (Vue 3 admin, modern PHP architecture, new conversion engine for WebP/AVIF, File System view, queue monitor, WP-CLI commands).
* Backwards compatible: legacy v1.x mode remains available and existing settings and attachment data are migrated in the background.

Older versions are listed in changelog.txt.
