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: 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.
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.
- Replace the hardcoded path in
gimp-diff.pywith the actual path of gimp - Run
build.pyto buildgimp-diff.exe - Place
plug-ins/diff.pyin 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.
- Open Android Studio
- Settings → Tools → Diff & Merge → External Tools
- Enable External Tools
- Add the tool executable as a merge and/or diff tool. Use the default argument order.
- Associate Images with the tool
This might end up being an included script.
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 git config --global difftool.gimp.cmd "\"<path-to-gimp-diff.exe>\" \"$LOCAL\" \"$REMOTE\""
git config --global diff.tool gimp 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 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 To test the merge tool when conflicts exist:
git mergetool --tool=gimp To test the diff tool:
git difftool --tool=gimp