Smaller pipeline output · Local · No upload

Optimize Rails Images — Before Precompile Runs

Compress the images in your Rails asset pipeline before precompiling — smaller deployed output, faster page loads, no precompile-time processing.

Quick answer

Drop your Rails project's app/assets/images folder into TinyPixels before running assets:precompile. It compresses every file in place, reducing your deployed asset pipeline output without any precompile-time processing.

How to compress images before Rails asset precompile

1

Download and open TinyPixels

Free to install on Mac or Windows — no account needed to start.

2

Drop app/assets/images in

Compress the images the asset pipeline will fingerprint and serve as-is.

3

Convert to WebP if desired

Get smaller output for hero images and view graphics.

4

Commit and precompile

Your deployed assets ship smaller with no gem or config changes.

The asset pipeline fingerprints files — it doesn't compress them

Rails' asset pipeline (Sprockets or the newer Propshaft, depending on your Rails version) handles fingerprinting, bundling, and cache-busting for static assets, but image content passes through completely unprocessed. Whatever size your images are in app/assets/images when assets:precompile runs is exactly the size that ships to production.

Compressing view graphics, hero images, and icons before committing solves this at the source, avoiding the need for a precompile-time gem that adds processing time to every deploy and CI run.

No precompile-time processing

Compress once before committing — no gem slowing down every deploy.

Direct impact on served assets

The pipeline fingerprints files as-is, so compression is directly reflected.

Bulk project processing

Compress your entire images folder in one pass.

Format conversion included

Convert to WebP for faster page loads across views.

Where image compression fits in a Rails project

A typical Rails app has images in a few distinct places, and the right fix depends on which one you're dealing with:

LocationWho controls itFix
app/assets/imagesDeveloper-committedPre-compress before committing — this page
app/javascript/images (jsbundling-rails)Developer-committedSame pre-compress approach, before webpack/esbuild bundles it
Active Storage uploadsUser-uploaded at runtimeHandle separately with a variant pipeline (e.g. image_processing gem + libvips), not a one-time pre-compress pass

TinyPixels solves the first two — static, developer-managed images — by compressing them before they ever enter the pipeline. It doesn't replace an Active Storage variant pipeline for user uploads, which needs to run per-upload at request time.

Common mistakes with Rails asset images

Committing raw design-tool exports

Images exported directly from Figma or Sketch are often far larger than necessary before any compression. Compress on export, not after the fact.

Relying on a compression gem in the precompile step

Gems that hook into assets:precompile re-run compression on every deploy and every CI build, adding time to a step that already blocks deployment.

Treating Active Storage variants as a replacement for source compression

Variants resize and re-encode on request, but they still start from whatever source file you uploaded — a bloated original slows every variant generation.

Skipping WebP because of an old asset pipeline habit

Modern Rails apps (7+) with import maps or jsbundling-rails have no issue serving WebP directly from app/assets/images — there's no bundler-specific limitation.

Frequently asked questions

Does the Rails asset pipeline compress images automatically?

No. rails assets:precompile fingerprints and copies image files for cache-busting, but it does not re-encode or compress image content. Images ship at whatever size they were added to app/assets/images.

Where should I compress images in a Rails project?

Compress images in app/assets/images before committing them. These are the files the asset pipeline fingerprints and serves, so pre-compression directly reduces what gets deployed.

Do image optimization gems slow down asset precompilation?

Gems that hook into the asset pipeline to compress images add processing time to every precompile step, including in CI and during deployment. Pre-compressing images locally before committing avoids this repeated cost.

Can I batch compress my whole Rails app/assets/images folder at once?

Yes. Drop your app/assets/images folder into TinyPixels and every file compresses in one pass, ready to commit before your next precompile.

Shrink your Rails asset pipeline output today

Free to start. No credit card, no account, no cloud. See Pro pricing →