Skip to content

About

Compress PNG, JPEG and WebP images entirely in your browser. No uploads, no server, no account - a privacy-first TinyPNG alternative that runs offline as a PWA.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

FreeImagePress

Compress images instantly. No uploads. 100% private.

MIT License Next.js No backend PRs welcome

FreeImagePress is a free, open-source alternative to TinyPNG that runs entirely in your browser. Drop in PNG, JPEG or WebP files, tune the compression quality, and download smaller images — without a single byte ever leaving your device.

FreeImagePress screenshot

Light theme screenshot

FreeImagePress light theme screenshot

Before you deploy: edit lib/site.ts (brand name, GitHub URL, descriptions, theme colors) plus the repository fields in package.json, then set NEXT_PUBLIC_SITE_URL at build time so canonical URLs, Open Graph tags and the sitemap point at your domain. Everything else works as-is.

Why another image compressor?

Most "free" compressors upload your files to a server, add watermarks, impose daily quotas, or ask you to create an account. FreeImagePress does none of that:

  • Private by architecture — compression runs in a Web Worker using the Canvas API, from a library payload that is vendored into the bundle. There is no upload endpoint to trust and no CDN call to audit.
  • Fast — no network round trip. A 20 MB batch is limited by your CPU, not your connection.
  • Free and open — MIT licensed, no accounts, no server bills, no tracking.
  • Yours to host — a static Next.js export that deploys to Vercel, Cloudflare Pages, Netlify, GitHub Pages, S3, or a Raspberry Pi.

Features

Compression

  • Drag and drop, file picker, or paste from the clipboard — up to 20 images per batch (20 MB each).
  • PNG, JPEG and WebP input with per-card thumbnails, pixel dimensions and byte counts for both the original and the result.
  • Per-image quality slider (10%–100%) plus a batch panel: quality presets (Extreme / Aggressive / Balanced / High fidelity), optional Convert to WebP, and a resolution cap (full, 4096, 2560, 1920 or 1280 px).
  • Up to three files encode in parallel in Web Workers with per-file and batch progress bars, and a Cancel action that aborts in-flight work through an AbortSignal.
  • JPEG EXIF is stripped, and the original bytes are kept when re-encoding would make the file larger.

Reviewing and exporting

  • Compare dialog with a draggable before/after divider and side-by-side metadata for each finished image.
  • One-click download per image, or Download All as a ZIP with live zip progress. Already-compressed payloads are stored, not re-deflated.
  • Unsupported formats, oversized files, duplicates and over-cap batches each get a specific sonner toast explaining what to do instead of a generic error.

Everyday polish

  • Light / dark / system theme, responsive from 320px phones to wide desktops (checked for horizontal overflow at 320 / 390 / 430 / 768 / 1024 / 1280 / 1920px), with 44px touch targets on every icon button below lg.
  • Keyboard shortcuts: Ctrl/⌘+Enter compress the batch, Ctrl/⌘+O browse, Ctrl/⌘+V paste, Esc closes dialogs.
  • Radix dialogs with focus trapping, ARIA live regions for progress, and WCAG AA contrast in both themes — audited with axe-core (0 violations across the landing page, the ready queue, the results grid and the compare dialog).
  • Toasts stack bottom-right on desktop and top-center on phones, so a notification never covers the button you just pressed.
  • Installable PWA: after the first visit the app shell and the compression worker are cached, so batching keeps working with the network switched off.
  • Offline status banner, install prompt, and an update toast that reloads only when you ask it to.
  • Static export — zero backend, zero database, zero env secrets.

Tech stack

Layer Choice
Framework Next.js 15 (App Router, static export)
Language TypeScript (strict)
UI Tailwind CSS + shadcn/ui
Components Radix UI primitives, custom shadcn-style components
Compression browser-image-compression
Drag & drop react-dropzone
Downloads file-saver + jszip
Icons lucide-react
Notifications sonner
Theming next-themes
PWA Hand-written service worker + web manifest (no next-pwa)
Fonts Geist (self-hosted, no external font requests)

How it works

flowchart LR
    A[Your device] -->|File API| B[Web Worker]
    B --> C[Canvas re-encode]
    C --> D[Compressed Blob]
    D --> E[Download or ZIP]
    F((No server upload)) -.-> A
Loading
  1. Files are validated by validateImageFile() in lib/compress.ts and read with the browser's File API. Previews are object URLs that are revoked when a card is removed, the workspace is cleared, or the component unmounts.
  2. scripts/vendor-worker.mjs (run automatically by prebuild) copies the browser-image-compression payload to public/vendor/browser-image-compression.js. At runtime that file is fetched once, republished as a blob: URL, and passed to the library as libURL. The library's jsDelivr default is therefore never reachable, which keeps both the strict CSP and the "no third-party requests" promise true even offline.
  3. compressImage() runs at most MAX_CONCURRENCY (3) encodes in parallel and forwards an AbortSignal, so Cancel terminates the worker instead of waiting for the encode. The library's raw progress numbers are smoothed into a monotonically rising 0–100 value for the progress bars.
  4. Results live in React state. Downloads use file-saver; "Download All" builds the archive with jszip using compression: "STORE", because the payloads are already compressed images. public/sw.js caches the shell, hashed chunks and the vendored worker so repeat visits (and offline visits) need no network.

PNG re-encoding is lossless, so the quality slider mainly affects JPEG and WebP. If the re-encoded file is not smaller, FreeImagePress keeps the original bytes and reports it as already optimized. Choosing Convert to WebP does trade format support for size — WebP is transparent-safe but no longer a PNG.

Quick start

Requirements

  • Node.js 18.18+ (Node 20 or 22 recommended)
  • npm, pnpm, yarn or bun

Development

npm install
npm run dev      # `predev` vendors the compression worker automatically

Open http://localhost:3000. Re-run npm run vendor manually only if you bump browser-image-compression without restarting the dev server.

Production build

npm run build   # vendor → next build (static site in ./out) → SEO + header gates
npm run start   # preview ./out with `serve` (applies out/serve.json headers)
npm run verify  # lint + typecheck + build

The project is a static export (output: "export"). There are no API routes, server actions, middleware or runtime environment variables required. postbuild runs two gates that fail the build: scripts/generate-seo.mjs writes out/sitemap.xml + out/robots.txt from NEXT_PUBLIC_SITE_URL and then re-reads out/index.html to assert the canonical link, OG image, twitter card, manifest, JSON-LD and description survived the export; scripts/check-headers.mjs verifies that vercel.json, public/_headers and public/serve.json still describe the same policy (run it on its own with npm run headers:check).

Deployment

Vercel

  1. Push the project to a GitHub, GitLab or Bitbucket repository.
  2. In Vercel, choose Add New → Project and import the repository.
  3. vercel.json declares everything: framework: null, installCommand: npm ci, buildCommand: npm run build, outputDirectory: out, trailingSlash: true.
  4. Set NEXT_PUBLIC_SITE_URL to your production domain so canonical and Open Graph URLs, robots.txt and the sitemap are correct. (If you skip it, the VERCEL_URL fallback is used automatically.)
  5. Deploy. Vercel serves the static export from its CDN and applies the security and cache headers from vercel.json.

The header policy is a strict same-origin CSP (script-src 'self' 'unsafe-inline' blob:, worker-src 'self' blob:, object-src 'none', frame-ancestors 'none'), HSTS, X-Content-Type-Options, Referrer-Policy, Permissions-Policy, and tiered Cache-Control: immutable for /_next/static/*, must-revalidate for sw.js and index.html, a week for image/icon assets, and a short stale-while-revalidate window for /vendor/*. Hashed font files stay immutable — the media rule deliberately excludes them. Bumping the service worker cache version is required whenever the caching strategy changes — see CACHE_VERSION in public/sw.js.

Cloudflare Pages

  1. Connect the GitHub repository in the Cloudflare dashboard under Workers & Pages → Pages → Create application → Connect to Git.
  2. Framework preset: Next.js (Static HTML Export).
  3. Build command: next build (or npm run build).
  4. Build output directory: out.
  5. Set NODE_VERSION to 20 or 22 if the build image uses an older default.
  6. Save and deploy. Cloudflare serves the files from its global network for free.

No Functions, Workers, bindings, databases or environment variables are needed. The optional NEXT_PUBLIC_SITE_URL variable is only used at build time for metadata. Cloudflare Pages picks up public/_headers automatically — the same policy as vercel.json, mirrored for hosts that read a _headers file (Cloudflare Pages and Netlify).

Any other static host

npm run build

Upload the contents of out/ to Netlify, GitHub Pages, S3 + CloudFront, nginx, Caddy, or any static file server. Serve index.html for /; no rewrite rules are required. public/serve.json is shipped into out/ as well, so npx serve out reproduces the production headers locally — use it to check the CSP before you deploy.

Service workers need a secure context. They will not register on plain http:// except on localhost; deploy over HTTPS.

Subdirectory hosting: the app assumes it is served from the domain root (/). For a project page such as example.com/freeimagepress, add basePath: "/freeimagepress" and assetPrefix: "/freeimagepress" to next.config.js and adjust the service worker paths accordingly.

Configuration

Edit these values in lib/compress.ts:

Constant Default Purpose
MAX_FILE_SIZE_MB 20 Maximum size per input image
MAX_FILES 20 Maximum images per batch
MAX_CONCURRENCY 3 Parallel Web Worker encodes
DEFAULT_QUALITY 0.8 Initial slider value
MIN_QUALITY / MAX_QUALITY 0.1 / 1 Slider bounds, also used to clamp input
DEFAULT_DIMENSION_CAP null Long-edge cap applied when no preference saved
QUALITY_PRESETS 4 items Batch preset buttons
DIMENSION_PRESETS 5 items Resolution-cap options
OUTPUT_FORMATS 2 items Keep format vs. convert to WebP

Other useful spots:

  • lib/site.ts — brand name, GitHub URL, license URL, SEO description, keywords and resolveSiteUrl().
  • lib/utils.ts — cn(), byte/dimension formatting, ZIP naming.
  • lib/prefs.ts — the localStorage keys for batch settings.
  • app/layout.tsx — metadata, Open Graph, robots/sitemap links.
  • app/globals.css — design tokens; --primary is tuned for AA contrast, so change it in both the light and dark blocks.
  • public/sw.js — offline cache. Bump CACHE_VERSION when the precache list or caching strategy changes; the old cache is deleted on activation and users are offered a refresh instead of a forced reload.
  • .env.example — optional build-time URL overrides.

Project structure

.
├── app/
│   ├── error.tsx                 # Route error boundary with a reset action
│   ├── globals.css               # Tailwind layers, shadcn tokens, safe-area utils
│   ├── layout.tsx                # Metadata, fonts, theme provider, toaster
│   ├── not-found.tsx             # Static 404 page
│   └── page.tsx                  # Hero, workspace, how-it-works + JSON-LD
├── components/
│   ├── ui/                       # shadcn-style primitives (button, dialog, …)
│   ├── BatchSettings.tsx         # Presets, WebP toggle, resolution cap
│   ├── CompareDialog.tsx         # Before/after slider viewer
│   ├── CompressionWorkspace.tsx  # State, batching, cancel, progress, ZIP
│   ├── Dropzone.tsx              # react-dropzone UI and rejection copy
│   ├── FaqSection.tsx            # <details> FAQ + FAQPage JSON-LD
│   ├── GitHubIcon.tsx            # Inline brand mark (Lucide dropped brand icons)
│   ├── ImageCard.tsx             # Per-image preview, quality, status, actions
│   ├── InstallPrompt.tsx         # beforeinstallprompt banner
│   ├── OfflineIndicator.tsx      # Online/offline status pill
│   ├── ServiceWorkerRegistrar.tsx# Registration + update-available flow
│   ├── SiteFooter.tsx / SiteHeader.tsx
│   ├── ThemeProvider.tsx / ThemeToggle.tsx
├── lib/
│   ├── compress.ts               # Worker pipeline, validation, concurrency
│   ├── download.ts               # Single + ZIP export helpers
│   ├── hooks.ts                  # online status, install, hotkeys, paste
│   ├── prefs.ts                  # localStorage-backed UI preferences
│   ├── site.ts                   # Brand / SEO identity + URL resolution
│   ├── types.ts                  # ImageItem and friends
│   └── utils.ts                  # cn(), formatting, naming helpers
├── scripts/
│   ├── generate-seo.mjs          # postbuild sitemap.xml + robots.txt + metadata self-check
│   ├── check-headers.mjs         # postbuild header-mirror parity gate
│   └── vendor-worker.mjs         # prebuild worker copy into public/vendor/
├── public/
│   ├── vendor/browser-image-compression.js  # self-hosted worker payload
│   ├── sw.js                     # Offline-first service worker
│   ├── manifest.webmanifest      # Icons, shortcuts, display mode
│   ├── _headers                  # CF Pages / Netlify header mirror
│   ├── serve.json                # `serve out` header mirror (local preview)
│   ├── icon.svg / icon-192.png / icon-512.png / apple-touch-icon.png
│   ├── favicon.ico / og-image.png / robots.txt
├── docs/                         # README screenshots
├── next.config.js                # output: "export", trailingSlash
├── vercel.json                   # Build + security/cache header configuration
└── package.json

Scripts

Command Description
npm run dev Start the Next.js dev server (vendors first)
npm run vendor Copy the compression worker into public/vendor/
npm run build prebuild vendor → next build → postbuild gates
npm run start Serve the production out/ folder with its headers
npm run lint Run ESLint (next lint)
npm run typecheck Run tsc --noEmit
npm run headers:check Assert vercel.json / _headers / serve.json agree
npm run verify Lint, type-check and build — the pre-PR gate

Privacy

  • Images are never uploaded. Compression happens in your browser tab.
  • No analytics, advertising, cookies or third-party requests: the app makes network calls only to its own origin (verified end to end — 56 requests in a full compress-and-download session, all same-origin).
  • No accounts, no server storage, no logs.
  • Fonts are bundled and the compression worker is vendored, so even the library never fetches from a CDN.
  • JPEG metadata (EXIF, including GPS) is stripped from the output.
  • A strict Content-Security-Policy blocks any script that is not served by the same origin, so a tampered dependency cannot silently phone home.
  • You can verify the behavior in DevTools → Network while compressing.

Limitations

  • Batch limits: 20 files, 20 MB each, 3 concurrent workers. This keeps memory use predictable on mobile devices.
  • Format support: PNG, JPEG (.jpg/.jpeg) and WebP only. GIF, AVIF, SVG, HEIC and animated images are intentionally out of scope — each of those gets a specific message instead of a silent drop.
  • PNG quality: PNG output is lossless; the quality slider has little to no effect until you convert to WebP.
  • Resolution: pixel dimensions are preserved by default. Use the resolution cap in the batch panel if you want the long edge trimmed (this is a resize, and it is applied before the quality pass).
  • Memory: very large batches on low-memory phones can still fail; the app shows an error per card instead of crashing the tab.
  • No crop/edit UI: FreeImagePress resizes and re-encodes, it does not crop, rotate or retouch.
  • Offline cache: the service worker precaches the app shell, icons, sitemap.xml, robots.txt and the vendored compression worker, and caches hashed chunks and fonts on first use. The very first visit still needs a network connection, and the origin must be HTTPS (or localhost).

Contributing

Issues and pull requests are welcome.

git clone https://github.com/aswindatha/freeimagepress.git
cd freeimagepress
npm install
npm run dev

Before opening a PR:

npm run verify   # lint + typecheck + production build

If your change touches the worker pipeline, also serve the export and run a manual pass: npm run start, then check DevTools → Network stays same-origin and that compression still works with the network set to Offline. Header files are guarded by npm run headers:check (part of postbuild), so a mirror drifting out of sync breaks the build instead of shipping silently.

Keep it backend-free — PRs that add API routes, databases, auth, tracking or paid tiers will be declined. New client-side features that preserve the privacy model are very welcome.

License

MIT © 2026 FreeImagePress contributors.

Inspired by TinyPNG's simplicity, rebuilt for the open web.


Made with ❤️ for the open web.

About

Compress PNG, JPEG and WebP images entirely in your browser. No uploads, no server, no account - a privacy-first TinyPNG alternative that runs offline as a PWA.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages