# Image Size Under X MB/KB Converter

[![Release](https://img.shields.io/badge/release-v1.0.0-indigo.svg)](https://aloks.com.np/utils/image-size-converter/)
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
[![Platform](https://img.shields.io/badge/platform-Web%20%7C%20Client--Side-brightgreen.svg)](https://aloks.com.np/utils/image-size-converter/)

An open-source client-side utility designed to automatically convert and compress images to fit strictly under any specified maximum file size (in KB or MB). Built with intelligent binary-search quality and dimension tuning, batch processing, side-by-side visual comparison, and dark/light mode.

Made with ❤️ in 🇳🇵 by Alok - [hello@aloks.com.np](mailto:hello@aloks.com.np).

---

## Key Features

- **Intelligent Target Size Compression**: Fits images strictly under your designated KB or MB limit (e.g. `< 500 KB`, `< 1 MB`, `< 200 KB`) using a fast binary search algorithm over canvas quality and scale factors.
- **100% Private Client-Side Processing**: All image transformations are executed in browser memory using HTML5 Canvas APIs. Zero upload to external servers.
- **Batch Processing & ZIP Export**: Drag and drop multiple files or folders, monitor compression progress in real-time, and download all compressed images bundled in a single `.zip` archive.
- **Interactive Visual Comparison Slider**: Inspect original vs compressed image quality side-by-side with a split-slider and real-time readouts of dimensions and file sizes.
- **Format Conversion**: Convert between JPEG (`.jpg`), WebP (`.webp`), PNG (`.png`), AVIF, and BMP formats.
- **Theme Toggle**: Light / System / Dark theme support with persistent browser memory.
- **Responsive & Accessible**: Optimized for mobile, tablet, desktop, and print environments.

---

## Quick Start

### Online Usage
Visit the live hosted utility directly on Alok's Utilities Hub:
[https://aloks.com.np/utils/image-size-converter/](https://aloks.com.np/utils/image-size-converter/)

### Local Development
1. Clone the repository:
   ```bash
   git clone https://github.com/aalooksth/aalooksth.github.io.git
   cd aalooksth.github.io/utils/image-size-converter
   ```
2. Open `index.html` in any web browser, or serve using any static web server:
   ```bash
   npx serve .
   ```
3. Run automated tests:
   ```bash
   node tests/compressor.test.js
   ```

---

## Tech Stack

- **Core**: Vanilla HTML5, JavaScript (ES6+), CSS3
- **Compression Engine**: HTML5 Canvas 2D Context, `toBlob` binary search
- **Typography & Icons**: Google Fonts (Outfit), FontAwesome 6
- **Archiving**: JSZip (CDN)

---

## Version History

### v1.0.0 (2026-09-08)
- Initial release of Image Size Under X MB/KB Converter utility.
- Added binary search compression engine (`compressor.js`).
- Implemented drag-and-drop batch queue with ZIP export.
- Added interactive side-by-side visual comparison split slider.
- Added dark, light, and system theme switcher.
- Added automated Node.js unit test suite (`tests/compressor.test.js`).

---

## Author & Attribution

Developed and maintained by **Alok Shrestha**.  
Website: [aloks.com.np](https://aloks.com.np) &bull; Email: [hello@aloks.com.np](mailto:hello@aloks.com.np)

*Made with ❤️ in 🇳🇵 by Alok*
