Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

gimp-diff

THIS IS A PROOF OF CONCEPT

This project enables GIMP to be used as a diff and merge tool for images.

Each image is loaded in its own layer with a subtraction filter applied to highlight the differences between each image.

The merge is considered complete when none of the layers overlap, identifiable when the filters have no discernible effect.

Usage

Usage: gimp-diff <local> <remote> [<base>] [<output>]

This will open a new GIMP instance, load the files, and wait for GIMP to be closed.

Calling with all four arguments will cause the program to return with 1 if output is changed at all during program execution, allowing it to be registered as a merge tool.

Building

This is currently in a "proof-of-concept" state, and as such the installation process is WIP.

I am very interested in learning a better way to deploy this app

This building method will be replaced as soon as that happens.

  1. Replace the hardcoded path in gimp-diff.py with the actual path of gimp
  2. Run build.py to build gimp-diff.exe
  3. Place plug-ins/diff.py in the corresponding plug-ins folder for GIMP, usually somewhere in appdata
    • This will also add the functions to GIMP for immediate use inside the application.

Adding

How to add to Android Studio

  1. Open Android Studio
  2. SettingsToolsDiff & MergeExternal Tools
  3. Enable External Tools
  4. Add the tool executable as a merge and/or diff tool. Use the default argument order.
  5. Associate Images with the tool

Configuring Git to Use GIMP for Image Merging and Diffing

This might end up being an included script.

Step 1: Configure gimp as a Merge Tool

Run the following command to set gimp as the merge tool (replace <path-to-gimp-diff.exe> with the actual path to your executable):

git config --global mergetool.gimp.cmd "\"<path-to-gimp-diff.exe>\" \"$LOCAL\" \"$REMOTE\" \"$BASE\" \"$MERGED\""
git config --global mergetool.gimp.trustExitCode true  

Step 2: Configure gimp as a Diff Tool

git config --global difftool.gimp.cmd "\"<path-to-gimp-diff.exe>\" \"$LOCAL\" \"$REMOTE\""
git config --global diff.tool gimp  

Step 3: Associate gimp with Image File Extensions

Set up Git to use gimp only for image files (e.g., PNG, JPG):

git config --global diff.image.command "\"<path-to-gimp-diff.exe>\" \"$LOCAL\" \"$REMOTE\""

Then, associate image file types with this diff driver:

git config --global diff.image.binary true  
git config --global diff.image.textconv ""  

Update .gitattributes to specify that images should use the image diff driver:

echo "*.png diff=image" >> .gitattributes  
echo "*.jpg diff=image" >> .gitattributes  
echo "*.jpeg diff=image" >> .gitattributes  

For merges, define a merge driver in .gitattributes:

echo "*.png merge=gimp" >> .gitattributes  
echo "*.jpg merge=gimp" >> .gitattributes  
echo "*.jpeg merge=gimp" >> .gitattributes  

Step 4: Enable gimp Only for Images

Modify the .gitconfig file to ensure gimp is only used for images. Open ~/.gitconfig (or C:\Users\YourUsername\.gitconfig) and add the following:

[merge "gimp"]
    name = GIMP image merge tool  
    driver = "<path-to-gimp-diff.exe>" %O %A %B %A  

Step 5: Test the Configuration

To test the merge tool when conflicts exist:

git mergetool --tool=gimp  

To test the diff tool:

git difftool --tool=gimp  

About

Proof of concept for using gimp as an image merge/diff tool

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages