by holman

diff images from the command line

444 Stars 12 Forks Last release: over 4 years ago (v1.0.3) MIT License 59 Commits 4 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:


diff images from the command line

what's inside™

Important business programmers don't have time to switch away from their terminal to view the diff of an image they're about to commit. The three seconds it takes to open an external diff visualization program could drive your sales team to drink and make inappropriate remarks to your new employees. Increase your productivity bottom line today, with


is a quick drop in to
. The idea is that you can just
git diff
like normal and, if you've changed an image file,
will render your images in a colorful ASCII approximation in your shell along with helpful data like file size changes.

Here's a quick example of what you might see:

spaceman screenshot

The goal is that

gives you a quick way of verifying that yes, the image you're committing is the image you want to commit, and yes, the image you're committing isn't accidentally 20 terabytes in size or something foolish like that.

Note: right now, spaceman-diff requires a change in the image; you won't see a diff rendered if you're simply adding or removing a file to your repo.

git diff
apparently doesn't pass things through to spaceman-diff at all in this case. There's probably a way to handle this, so pull requests accepted.


There are two dependencies that you need before you can fiddle with pixels and characters and junk: jp2a and ImageMagick.

handles conversion of a JPEG to ASCII, and ImageMagick can do everything from image conversion to probably running a nuclear reactor.

os x

If you're using Homebrew, blindly run this:

brew install jp2a imagemagick


If you're using

, you should be able to install your dependencies in a similar manner:
sudo apt-get install jp2a imagemagick


Once you have your dependencies installed, drop

onto your system or your dotfiles directory or whatever kooky stuff you're using. If you're using Homebrew, you can instead install

brew install spaceman-diff
. After that, you need to configure Git to use
for all your image diffs.

If you don't have one already, create a file at

and add this to it:
*.png  diff=spaceman-diff
*.jpg  diff=spaceman-diff
*.jpeg diff=spaceman-diff
*.gif  diff=spaceman-diff

This basically tells Git to use the

strategy to render the diff for these four particular file extensions.

Next, you need to tell Git about spaceman-diff. Do that by editing

[diff "spaceman-diff"]
  command = /path/to/spaceman-diff

At this point, you should be ready to go. Try it out on a directory with an unstaged image change and run it with

git diff


Send a pull request with your changes, and make sure the tests pass. You can run dem tests with

in your working directory.


This was cobbled together by @holman.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.