toy/image_optim
56.9
Adequate · 19 September 2026
2.7k
lines of production code
Ruby
primary language
1
measurement over time
What this system is
This system is a Ruby library and command-line tool for optimizing image files by wrapping various external optimization utilities. It provides a modular architecture to manage workers for formats like PNG, JPEG, and SVG, supporting features such as lossy/lossless optimization, caching, and benchmarking. The tool handles binary resolution, version validation, and configuration to ensure reliable image processing across different environments.
How it got here
2012 — Core architecture refactoring and modularization
8 changes.
This period focused on a major refactoring of the ImageOptim core, replacing the monolithic implementation with a modular architecture featuring dedicated Handler and Cache classes. The work introduced significant new features including disk-based caching, benchmarking capabilities, and support for additional image workers like jpeg-recompress and svgo. Additionally, the project established robust testing infrastructure, standardized CLI behavior, and modernized its development environment with RuboCop and Docker support.
2013–2015 — refactoring and test expansion
12 changes.
This period focused on strengthening the project's reliability through extensive refactoring of the binary resolution system and CLI option parsing. Comprehensive test suites were added for core components, workers, and utilities, alongside new tools for image optimization and automated maintenance.
Features
Added jpegrescan tool for optimizing JPEG progressive scan orders
A new vendor utility, \jpegrescan\, has been added to the project to optimize JPEG files by trying various progressive scan orders and selecting the one that results in the smallest file size. The tool is provided as a Perl script for Unix-like systems and includes a Windows batch wrapper (\jpegrescan.bat\) to ensure cross-platform compatibility. Users can now leverage this tool to potentially reduce JPEG file sizes by adjusting scan patterns.
vendor · high confidence
Image optimization now supports caching and benchmarking
The library now includes a caching system that stores optimized images to disk, significantly speeding up subsequent runs by skipping already-processed files. A new \--benchmark\ mode has been added to the runner, allowing users to measure and compare the performance of different optimization workers. Additionally, the runner now supports exclusion patterns via \--exclude-dir-glob\ and \--exclude-file-glob\ options to filter out specific files or directories during recursive optimization.
_lib/image\optim · high confidence
Initial repository setup with pre-commit hook and RuboCop configuration
The repository now includes a \.pre-commit-hooks.yaml\ file to register \image\_optim\ as a pre-commit hook for image files, requiring \image\_optim\_pack\ as a dependency. A comprehensive \.rubocop.yml\ configuration is added to enforce code style, including a 120-character line length limit, specific layout and style rules, and exclusions for test files and generated scripts. Additionally, a \Dockerfile.test\ is introduced to build test environments across multiple Ruby versions using GitHub Actions, and the \CHANGELOG.markdown\ is initialized with version history up to v0.32.0.
(repo-wide) · high confidence
New scripts for worker analysis and README maintenance
Added \script/worker\_analysis\ to evaluate and compare image optimization worker performance, including caching results via GDBM and generating detailed statistics. Added \script/update\_worker\_options\_in\_readme\ to automatically regenerate the worker options section in the README based on current worker definitions. Added \script/update-rubygems-n-bundler\ to automate the installation and updating of RubyGems and Bundler versions across different Ruby versions.
script · high confidence
Behavioural changes
Introduce CLI entry point with verbose error reporting
The \bin/image\_optim\ script is introduced as the command-line entry point, delegating argument parsing to \ImageOptim::Runner::OptionParser\ and execution to \ImageOptim::Runner\. A key behavioral change is that when the \--verbose\ flag is used, the tool now outputs the full exception backtrace on failure, whereas previously it likely only showed the error message. It also displays the full version string in verbose mode and aborts with specific messages if no paths are specified or if optimization fails.
bin · high confidence
Major refactoring of ImageOptim core architecture and interface
The lib/image\_optim.rb file has been completely rewritten to introduce a modular architecture, replacing the previous monolithic implementation. This change introduces new configuration options including cache directories, worker digest caching, per-image timeouts, and the ability to skip missing workers or allow lossy optimizations. The core optimization logic is now delegated to dedicated Handler and Cache classes, and the return type for single-image optimization methods has changed to return an OptimizedPath object instead of a simple path. Additionally, the library now supports a broader set of image workers (such as jpeg-recompress, oxipng, and pngquant) and requires Ruby 1.9.3 or higher.
lib · high confidence
Major refactoring of worker architecture and addition of new image optimization tools
The worker implementation has been restructured to use a new \ClassMethods\ module for managing worker registration, option definitions, and initialization, replacing the previous hash-based approach. This refactor introduces a unified \OptionDefinition\ class and explicit \run\_order\ values to control execution sequence. Several new optimization workers have been added, including support for \jpeg-recompress\, \Oxipng\, and \svgo\ (with specific handling for versions 2.x and 3.x). Existing workers have been updated: \Gifsicle\ now runs twice (interlace on/off) for better compression, \Optipng\ and \Pngcrush\ have refined option handling and version checks, and \Jpegtran\ now defaults to using \jpegrescan\. Additionally, \TrueFalseNil\ handling and \allow\_lossy\ options have been standardized across workers to improve consistency and user control over lossy/lossless modes.
_lib/image\optim/worker · high confidence
Refactored CLI option parsing and added glob brace expansion support
The command-line interface now uses a dedicated \OptionParser\ class to handle argument parsing, resulting in improved help text wrapping and indentation that adapts to terminal width. Additionally, a new \GlobHelpers\ module has been introduced to expand curly braces in glob patterns, ensuring compatibility with Ruby versions prior to 2.0 that lack native support for this feature.
_lib/image\optim/runner · high confidence
Refactored binary version detection and validation logic
The binary resolution system has been restructured to improve how external image optimization tools are detected and validated. A new \SimpleVersion\ class enables robust semantic version comparison, while \ComparableCondition\ allows for cleaner, declarative version checks. The \Bin\ class now centralizes version detection for tools like pngcrush, pngquant, optipng, and jpeg-recompress, and enforces strict failure or warning conditions based on specific version ranges (e.g., blacklisting pngcrush 1.7.80 due to color loss). This refactoring ensures that incompatible or buggy tool versions are caught early, providing clearer error messages and preventing silent corruption of optimized images.
_lib/image\_optim/bin\resolver · high confidence
Test coverage
Added test coverage for GlobHelpers and OptionParser; Added test coverage for core image optimization components; Added test coverage for image optimization workers; Added test fixture for images with fully transparent pixels; Added test fixtures for image processing specs; Added test image generation script for orientation tests; Added test image generation script for quantization specs; Added tests for bin\_resolver version comparison logic; Initial test suite for ImageOptim core functionality.
Dependencies
Added jQuery 2.1.3 library to script/template directory
The script/template directory now includes the jQuery 2.1.3 minified library (jquery-2.1.3.min.js), making this version of jQuery available for use in worker analysis templates and scripts located in this directory.
script/template · high confidence
Update to version 0.32.0 with Ruby 4 support and modernized dependencies
This release updates the gem to version 0.32.0 and introduces support for Ruby 4 by conditionally requiring the 'logger' gem in the Gemfile. It adds SVG optimization support via the 'svgo' worker and updates the summary to reflect additional supported utilities like jhead, jpeg-recompress, and oxipng. Dependency constraints have been refreshed, including 'fspath' \~\> 3.0, 'image\_size' \>= 1.5, and 'exifr' \~\> 1.2, while development dependencies now include 'rubocop' \~\> 1.90 and 'rubocop-rspec' \~\> 2.0 for Ruby 2.7+ environments. The gemspec also adds metadata URIs and a post-install message noting that Rails integration has been extracted to a separate gem.
(dependencies) · high confidence
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
How this codebase got here
Baseline
- First survey — no prior run to compare against. CAI 57.
Lenses
- Code Health 100
- Architecture 96
- Maturity 59
- Readiness 69
- Security 77
- Accessibility 43
Changes since last survey
- 300 commits — 273 feature/other, 27 fixes
By area
- (root) — 169 commits
- .github/workflows — 49 commits
- lib/image_optim — 41 commits
- spec/image_optim — 11 commits
- (repo) — 10 commits
- .github/dependabot.yml — 5 commits
- spec/image_optim_spec.rb — 4 commits
- script/update_worker_options_in_readme — 2 commits
- script/worker_analysis — 2 commits
- spec/images — 2 commits
- vendor/jpegrescan — 2 commits
- bin/image_optim — 1 commit
- spec/spec_helper.rb — 1 commit
- vendor/jpegrescan.bat — 1 commit
Notable commits
- fix: --benchmark, fixes #217 (#218)
- fix: Fix error: uninitialized constant EXIFR::JPEG, close #150
- fix: Fix: TypeError: can't convert ImageOptim::Timer into Float
- fix: Revert "disable AbcSize and CyclomaticComplexity for Bin#version_string"
- fix: Revert "forbid rspec-expectations 3.8.3"
- fix: fix and update jpegoptim list of markers, resolves #188
- fix: fix badges
- fix: fix cache spec by stubbing mkdir (Pathname#mkpath is not using FileUtils anymore)
- fix: fix changelog uri in gemspec
- fix: fix codeclimate badge
- fix: fix codeclimate coverage badge
- fix: fix config scripts failing due to implicit-function-declaration
- fix: fix help text wrapping logic
- fix: fix jpegrescan for windows
- fix: fix jruby exposing expect been thread unsafe, also allow is sufficient
- fix: fix links in changelog entries
- fix: fix ruby 3.2 compatibility in test
- fix: fix script/update_worker_options_in_readme failure due to frozen string
- fix: fix spec for caching already optimised images
- fix: fix spec for ruby 3.1
- …and 280 more
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
Survey your own repository
toy/image_optim was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.
About this page
- The score is its most recent published measurement, taken on 19 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
- Measured at commit 7d37cb8218231f7f66d75a2b5fe9443265cebada — the exact code this score is about.
- Scored under rubric-2026.09.15 — the same rubric and the same method as every other entry in this index.
- Measured by watchdog.canine.dev using codehealth-analyzer preprod-b51f968c9b10.