=== Codcy Image Optimizer ===
Contributors:      codcy
Tags:              image optimization, webp, compress images, media library, performance
Requires at least: 5.8
Tested up to:      6.9
Stable tag:        1.6.3
Requires PHP:      7.4
License:           GPLv2 or later
License URI:       https://www.gnu.org/licenses/gpl-2.0.html

Bulk convert JPEG and PNG images to WebP. No external service. Runs entirely on your server with automatic backup.

== Description ==

**Codcy Image Optimizer** converts your existing JPEG and PNG images to WebP format in bulk — directly on your server, with no third-party API or paid subscription required.

WebP images are significantly smaller than JPEG and PNG files (typically 60–95% smaller), which leads to faster page loads, lower bandwidth usage, and better Core Web Vitals scores.

**How it works:**

1. **Scan** — Analyzes your entire Media Library. Shows total image count, file size, and format breakdown before any changes are made.
2. **Review** — You decide when to start. Nothing is changed until you click Start.
3. **Optimize** — Converts images in batches of 20. Originals are backed up automatically.
4. **Report** — A detailed summary shows converted count, space saved, average compression rate, and any errors.

**Key features:**

* Converts JPEG and PNG to WebP
* Automatic backup of original files to `uploads/codcy-image-optimizer/backup/`
* Skips images where WebP would be larger than the original
* Fixes EXIF orientation automatically (Imagick)
* Resumes from where it left off if interrupted
* Does not alter image dimensions or crop ratio
* No external API, no account required
* Works with Imagick (preferred) or GD Library

**What it does NOT do (intentionally):**

* Does not resize images
* Does not process GIF files (may contain animation)
* Does not delete backups automatically

== Installation ==

1. Upload the plugin files to `/wp-content/plugins/codcy-image-optimizer/`, or install the plugin directly through the WordPress Plugins screen.
2. Activate the plugin through the **Plugins** screen.
3. Go to **Media > Image Optimizer** in your WordPress admin.
4. Click **Scan Media Library**, review the results, then click **Start Optimization**.

== Frequently Asked Questions ==

= Does this use an external service? =

No. All processing happens on your server using PHP's Imagick or GD extension. No data is sent anywhere.

= Will my original images be deleted? =

No. Originals are copied to `uploads/codcy-image-optimizer/backup/` before conversion. The backup directory is protected from public access.

= What if the optimization is interrupted? =

The plugin tracks progress in the database. If you stop mid-way, clicking **Start Optimization** again will resume from where it left off. Use **Reset Progress** only if you want to start fresh.

= Does it work with WooCommerce product images? =

Yes. All images in the WordPress Media Library are processed, including WooCommerce product images.

= What image quality setting does it use? =

WebP quality is set to 82/100 by default, which provides an excellent balance between file size and visual quality.

= Is Imagick required? =

No. The plugin works with GD Library as well, which is available on most hosting environments. Imagick is preferred because it also corrects EXIF orientation.

= Will this affect my image URLs? =

The plugin updates the attachment record in WordPress, so URLs served by WordPress will automatically point to the new WebP file. Note: CDN-served URLs may need cache clearing.

== Screenshots ==

1. Plugin overview and server status
2. Scan results — image count, total size, and format breakdown
3. Optimization in progress with live log
4. Final report with detailed statistics

== Changelog ==

= 1.6.0 =
* Fixed: JS and CSS are now loaded via wp_enqueue_script/wp_enqueue_style instead of inline output.
* Fixed: Removed load_plugin_textdomain() — WordPress.org handles translations automatically.
* Fixed: Removed directory assets (screenshots, icons) from plugin ZIP — these are uploaded via SVN separately.

= 1.5.1 =
* Added: Existing WebP images are now optimized too — images wider than 1200px are resized, images larger than 500KB are recompressed.
* Added: Original WebP files are backed up before reprocessing.
* Improved: WebP images already within limits (under 1200px and under 500KB) are skipped automatically.

= 1.1.0 =
* Added: 45-second timeout per batch — stuck requests are automatically skipped.
* Added: Auto-retry logic — after 3 consecutive failures, the stuck batch is force-skipped and processing continues.
* Added: Skip images that already have a .webp version on disk (previously optimized by any plugin).
* Improved: Batch processing is now more resilient on slow or shared hosting.

= 1.0.0 =
* Initial release.

== Upgrade Notice ==

= 1.0.0 =
Initial release.
