=== ShrinkTo - Browser-Native Image & PDF Compressor ===
Contributors: dakshu007
Tags: image compression, image optimizer, pdf compressor, webp, image resizer
Requires at least: 5.5
Tested up to: 6.9
Requires PHP: 7.4
Stable tag: 1.0.0
License: GPL v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Compress images and PDFs to exact KB targets directly in your WordPress admin. Runs in the browser using Canvas and pdf-lib.

== Description ==

ShrinkTo lets you compress images and PDFs in the WordPress admin without any server-side processing. The compression runs inside the admin user's browser using the HTML Canvas API for images and the pdf-lib library for PDFs. The plugin does not transmit image or PDF data to any external service for compression.

= What it does =

* **Image compression** with exact-KB targeting using a binary-search algorithm. Set a target like 50 KB and the plugin lands within 0.5 KB of the target.
* **PDF tools** for compress, merge, PDF→JPG, and JPG→PDF. Powered by the bundled pdf-lib and pdf.js libraries running locally.
* **Format conversion** for JPG, PNG, WebP output. HEIC iPhone input is auto-converted.
* **Auto-resize** before compression to a configurable maximum dimension (default 1920 px).
* **Bulk library re-processing** to re-compress your existing WordPress media library against current settings.
* **Indian government exam presets** — one-click compression for SBI Clerk, IBPS PO/Clerk, UPSC CSE, SSC CGL, NEET, JEE, RBI, GATE, and more. Specs sourced from each exam's current notification.
* **Performance dashboard** with compression count, bytes saved, and a PageSpeed Insights audit fetcher (uses Google's public PSI API).

= Privacy =

The compression operations themselves do not send image or PDF data outside the user's browser. You can verify this by opening DevTools → Network in your admin browser before clicking compress — no outbound requests carry image or PDF payload data.

The admin UI loads Google Fonts CSS (for the Inter typeface and Material Symbols icons) and the PageSpeed Insights audit feature contacts Google's public PSI API when explicitly triggered. Both are documented in the External Services section below.

== Installation ==

= From WordPress.org =

1. Go to **Plugins → Add New** in your WordPress admin.
2. Search for **ShrinkTo**.
3. Click **Install Now**, then **Activate**.
4. Open **ShrinkTo → Dashboard** in the admin sidebar.

= Manual installation =

1. Download the ZIP.
2. Go to **Plugins → Add New → Upload Plugin** and select the ZIP.
3. Click **Install Now**, then **Activate**.

= Quick start =

1. Open **ShrinkTo → Image Compression**.
2. Drop an image into the upload area or click to browse.
3. Pick a target size (e.g. 50 KB) or choose an exam preset.
4. Click **Compress**.
5. Download the result, or save it back to the media library.

For PDFs: open **ShrinkTo → PDF Tools** and use the Compress, Merge, PDF→JPG, or JPG→PDF tools the same way.

== Frequently Asked Questions ==

= Does the plugin send my images to a server? =

The compression itself runs in the admin user's browser via Canvas and pdf-lib. You can verify in DevTools → Network: there are no outbound requests carrying image or PDF data during compression.

= Will it slow down my WordPress site or hosting? =

The compression runs in the admin browser, not on the WordPress server, so there is no server CPU cost during compression operations.

= Does it work on shared hosting? =

Yes — it does not require ImageMagick, GD, or any server-side image processing libraries.

= Are HEIC iPhone photos supported? =

Yes. HEIC files are decoded in the browser and re-encoded as JPG, WebP, or PNG during compression.

= Can I bulk-process my existing media library? =

Yes. Open **ShrinkTo → Bulk Library** and start the bulk queue. Each item is processed sequentially in the admin tab. Closing the tab pauses the queue; reopening resumes it.

= What about animated GIFs and SVGs? =

GIFs are not currently re-encoded (planned for 1.1). SVGs are minified (whitespace stripped) but kept as SVG, since they are vector and don't benefit from raster compression.

= Will it conflict with other image plugins? =

The plugin does not hook into the WordPress server-side upload pipeline, so it generally coexists with other image plugins. If you use another compressor in parallel, your images will be double-compressed.

= How do I uninstall completely? =

Deactivate then delete the plugin from the Plugins page. The plugin's options and stats are removed via uninstall.php. Your media library files are not touched.

= Does it require JavaScript? =

Yes. The compression engine is JavaScript-based. With JavaScript disabled, the admin UI loads but compression operations cannot run.

== Screenshots ==

1. Dashboard with compression statistics.
2. Image compression page with KB target chips and format selection.
3. Exam presets — Indian government exam dimensions and KB caps.
4. PDF Tools page with Compress, Merge, PDF→JPG, and JPG→PDF.
5. Bulk Library processor for re-compressing existing media.
6. Performance page with PageSpeed Insights integration.
7. Settings page.

== Changelog ==

= 1.0.0 — May 2026 =
* Initial release.
* Browser-based image compression with binary-search KB targeting (Canvas).
* PDF compression, merge, PDF→JPG, and JPG→PDF tools (pdf-lib + pdf.js).
* JPG, PNG, WebP output. HEIC input.
* Auto-resize with configurable max dimension.
* Indian government exam presets (SBI, IBPS, UPSC, SSC, NEET, JEE, RBI, GATE, etc.).
* Bulk media library re-compression.
* Performance dashboard with PageSpeed Insights audit.
* Translation-ready (text domain: shrinkto).
* WordPress 5.5+ and PHP 7.4+.

== Upgrade Notice ==

= 1.0.0 =
Initial release.

== External Services ==

This plugin contacts the following external services:

**1. Google Fonts** (`fonts.googleapis.com`, `fonts.gstatic.com`)

* Purpose: load the Inter typeface and Material Symbols Rounded icons for the admin UI.
* Data sent: standard HTTP request; no personal data, no image data.
* When: only on plugin admin pages while the admin user is logged in.
* Service terms: https://developers.google.com/fonts/faq
* Privacy policy: https://policies.google.com/privacy

**2. Google PageSpeed Insights API** (`www.googleapis.com/pagespeedonline/v5/runPagespeed`)

* Purpose: when the admin clicks "Run audit" on the Performance page, fetch a PageSpeed score for the current site's homepage URL.
* Data sent: the site's homepage URL (which is already public).
* When: only when an admin user clicks the audit button.
* Service terms: https://developers.google.com/speed/docs/insights/v5/about
* Privacy policy: https://policies.google.com/privacy

The compression operations themselves do not contact any external service.
