Skip to content

About

A single-page tool that reads an image's aspect ratio, trims letterbox/pillarbox bars, and previews cinema framings via browser.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

14 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ImageAnalyzer / Aspect Ratio Detector

A single-page tool that reads an image's aspect ratio, trims letterbox/pillarbox bars, and previews cinema framings via browser. (No cloud)

This tool also allows you to quickly preview the metadata of each image, giving you a deeper insight.

Usage

To first access the app, go to this link here. It is hosted as a GitHub Pages, but it all runs on your machine.

  1. Drop an image (or click to browse) - PNG, JPG, WEBP, GIF, AVIF all work.
  2. The raw aspect ratio appears immediately, as a decimal (2.39:1) and a simplified whole-number ratio (16:9), with a note if it's close to a known cinema ratio.
  3. If your image has solid-colour letterbox/pillarbox bars, check "Ignore borders" to see the ratio recalculated without them. The border colour defaults to black - pick a different one with the colour swatch or the eyedropper if your bars aren't black.
  4. Pick a reference ratio from the dropdown next to the preview to see dark mattes showing how the image would be cropped at that framing (16:9, 2.39:1 Scope, etc.).
  5. Once something is actually cropped - borders trimmed, or a reference ratio that cuts into the image. Save Image writes that exact rectangle out at full source resolution. It saves the reference framing when one is selected, otherwise the detected content area, and the note beside the button always spells out which one and at what size. Nothing is cropped, nothing to save: the button stays disabled. Exports keep the original format where the browser can encode it (PNG, JPG, WEBP) and fall back to PNG otherwise, named original-cropped-1920x800.png.
  6. The Meta Data panel lists whatever the file exposes, grouped by kind: file name, MIME type, size, last-modified date, and a SHA-256 hash; format, resolution, bit depth/colour type, and (for PNG) DPI and gamma; and, where present, EXIF camera settings, GPS coordinates (with a link to view them on OpenStreetMap), XMP/IPTC titles and keywords, GIF/WEBP/APNG animation info, and an embedded ICC colour profile. Groups only appear when the file actually has that data - a plain screenshot won't show camera or GPS fields.

How it works

Border detection

A pixel counts as "border" if its colour is close enough to your chosen border colour measured as straight-line distance in RGB space, within a tolerance you can adjust (default 20 out of a max ~441). This is deliberately loose enough to absorb compression noise around the true colour, but tight enough that real image content never qualifies.

A whole row (or column) counts as a border row once 98% of its sampled pixels match (not 100%), since a single stray pixel or a subtitle's antialiased edge would otherwise stop the scan on the very first row. The scan walks inward from each of the four edges independently and stops at the first row/column that fails the 98% test, so asymmetric bars (e.g. 164px top, 100px bottom) are handled correctly.

Two safety nets: a side with no matching border pixels reports 0px rather than forcing a crop, and if a detected crop would remove more than ~95% of an axis (an image that's almost entirely the border colour), the crop is discarded for that axis and a warning is shown instead of a nonsense ratio.

Images do not get downscaled whatsoever, so be wary of uploading large files.

Deploying your own copy

Since it's a static site, there is no build step, no dependencies. Push index.html, style.css, and script.js to a repo's default branch, then enable Settings → Pages → Deploy from a branch on main / root.

Credits

About

A single-page tool that reads an image's aspect ratio, trims letterbox/pillarbox bars, and previews cinema framings via browser.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages