=== LeanPixel – Image Optimizer ===
Contributors: leanwptools
Tags: image optimization, image compression, compress images, webp, avif
Requires at least: 5.8
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Image optimization that compresses your images and creates WebP and AVIF versions, through our service or on your own server. Originals are kept.

== Description ==

LeanPixel makes the images on your site smaller so pages load faster. It is part of [LeanWPTools](https://leanwptools.com/): lightweight WordPress tools without the bloat. By default the compression runs on our servers, not on yours, so it works on any hosting plan and does not slow your site down while it runs. If you would rather not send your images anywhere, one switch makes LeanPixel do the work on your own server instead.

**LeanPixel is free to use.** The free plan covers 1,000 images a month on one website through our service, and processing on your own server has no limit. Paid plans at https://my.leanwptools.com/ add more images a month, more sites per key, and AVIF versions. Every setting in the plugin is the same on every plan.

* Optimizes new uploads automatically, including every thumbnail size
* Bulk optimizer for the images already in your media library, running in the background
* Three compression levels: lossless, balanced and aggressive
* Creates WebP versions, and AVIF versions on paid plans or on your own server, and can serve them to browsers that support them
* Resizes oversized images to a maximum size you choose
* Optimize or restore several selected images at once from the media library
* Keeps your originals and restores them with one click
* Exclude rules for folders or files you want left alone
* Optional: process images on your own server, with no account and nothing sent anywhere
* Optional: load your images from a CDN by entering its address, with set-up steps for Bunny CDN
* Works with JPEG, PNG and GIF

== External services ==

By default this plugin uses the LeanPixel image optimization service to compress your images. Using the service is optional: with "Process images on this server" switched on, the plugin does the work on your own server and does not contact the service at all.

Nothing is sent until you connect the plugin on the Media → LeanPixel screen. When the service is in use:

* **When you connect:** the email address you enter, your site address and a one-time random secret (used only for the site check below) are sent to create your API key. A 6-digit code is then emailed to that address by LeanWPTools; the key starts working once the code is entered on the LeanPixel screen.
* **When you confirm your email address:** the code you enter, or a request for a new code, is sent with your API key.
* **When an image is optimized** (on upload, in a bulk run, or when you click Optimize): the image file, your API key, your site address, your chosen compression settings and a random-looking id for the image (so its thumbnails are counted as one image) are sent. The service returns the optimized file and the WebP/AVIF versions. Uploaded images are deleted from the service as soon as each request finishes.
* **When you open the LeanPixel screen:** your API key is sent to read your plan and monthly usage.
* **With every request:** your site address and the plugin's version are included (in the request headers), so usage is counted for the right site.
* **Site check (free plan):** to confirm a free key is used on the site it belongs to, the service visits your site once at `/?leanpixel_verify=…` when you request a free key, and when a free key is first used on a site. The plugin answers with a one-way code made from the key; the key itself is never sent. Free keys therefore need a site the service can reach over the internet; paid keys are not checked.

The service is LeanWPTools, provided by Complete Digital Solutions, LLC, at `api.leanwptools.com`.
Terms of service: https://leanwptools.com/terms
Privacy policy: https://leanwptools.com/privacy-policy

The screen links to your account at https://my.leanwptools.com/, where you can see your API keys and manage a paid plan. The plugin itself sends nothing to that address.

**CDN (optional).** If you enter a CDN address in the settings, the plugin points the image addresses on your public pages at that CDN, so your visitors' browsers load images from it. When you save a new address, the plugin requests one of your images through it once, to check that it works. Which CDN you use is your choice and is governed by that provider's terms. The plugin does not create a CDN account or send anything to a CDN provider on your behalf.

The set-up steps on the settings screen use Bunny CDN as the example and contain an affiliate link to bunny.net, labelled as such: we (Complete Digital Solutions, LLC) may earn a commission if you sign up through it. You do not need Bunny, or any CDN, to use the plugin.
Bunny terms: https://bunny.net/tos/
Bunny privacy policy: https://bunny.net/privacy/

== Installation ==

1. Install and activate the plugin.
2. You are taken to Media → LeanPixel (you can also find it there later).
3. Enter your email address and click "Get my free API key".
4. Click "Optimize all images" to process your existing library. New uploads are optimized automatically.

== Frequently Asked Questions ==

= Is it really free? =

Yes. The free plan covers 1,000 images per month through the service, for one website. Each image counts once, however many thumbnail sizes WordPress makes from it. Each website can use one free key, and the site must be reachable from the internet (local and password-protected sites can use a paid key, or process images on their own server). Processing on your own server has no limit.

= Can I use it without sending my images to your servers? =

Yes. On the Media → LeanPixel screen choose "Process images on this server". No account or API key is needed and nothing leaves your site. The plugin then uses the image library your host provides for PHP (Imagick or GD).

There are trade-offs. It is slower than the service, and much slower on a small hosting plan, because your own server does all the work. Savings are also smaller, most of all for PNG images. GIF images are left as they are. WebP and AVIF versions are created only if your server's image library can write them; the screen tells you which it can.

= Can I get my original images back? =

Yes, as long as "Keep a copy of every original" is switched on (it is by default). Use "Restore original" next to the image in the media library. Originals are stored in a folder inside `wp-content/uploads/` whose name starts with `leanpixel-backup-`; the exact name is shown on the settings screen. The folder is blocked from web access.

= How are the WebP and AVIF versions served? =

They are saved next to the original, for example `photo.jpg.webp`. With "Serve the WebP/AVIF version" switched on, the plugin adds rules to your site's main `.htaccess` file so browsers that support the format receive it at the same address. This works on Apache and LiteSpeed. On nginx the plugin shows the rules to add to your server configuration.

= How do I use a CDN? =

Enter your CDN's address under Media → LeanPixel → Settings → CDN. Images in your uploads folder are then loaded from the CDN on your public pages. Nothing is changed in your posts, so clearing the box puts everything back. The settings screen has step-by-step instructions for Bunny CDN; any CDN that pulls files from your site works the same way.

If you also serve WebP/AVIF versions, set the CDN to keep separate copies for browsers with and without WebP/AVIF support (on Bunny: Caching → General → Vary Cache → "WebP support" and "AVIF support").

= What happens if I remove the plugin? =

Your images stay optimized and the kept originals stay in the backup folder. Settings and per-image records are deleted.

== Changelog ==

= 1.0.0 =
Initial release.

* Compresses images automatically when you upload them, thumbnails included.
* Bulk optimizer for the images already in your media library. It works in the background and resumes by itself after a pause.
* Three compression levels: Lossless, Balanced and Aggressive.
* Creates WebP versions (and AVIF on paid plans) and serves them to browsers that support them.
* Resizes oversized images to a maximum size you choose.
* Keeps your originals in a private folder, so any image can be restored. Delete them whenever you like.
* Removes camera and location details from photos, unless you choose to keep them.
* Exclude rules for folders or files you want left alone.
* Optional processing on your own server, with no account and nothing sent anywhere.
* CDN setting, with set-up steps for Bunny CDN.
* Savings shown in the media library and on the LeanPixel screen.
* Free plan: 1,000 images a month on one website. Each image counts once, however many thumbnail sizes it has.
* Free API keys are switched on with a code sent to your email address.
