Applying a high pass filter to multiple files


currently I’m manually doing the routine below:

  • convert color profile from embedded to GIMP
  • duplicate layer
  • run High Pass Filter profile on duplicated layer
  • set blend mode to Soft Light
  • Merge Down
  • Export as jpeg with quality 100

The question is, I have over 500 files that I need to do this routine on. Currently I have been manually doing it on many but it’s quite time consuming.
Is there a way to script or automate this process in GIMP?

I have been reading up on scripting in GIMP and from what I have read the script language is LISP but unfortunately I haven’t found any tutorial or example that I could understand to modify for my needs.

Does anyone know of any sample code on how to do something similar that I can work my way around from there??



GIMP is not IMO the ‘tool’ you need. There are several that are which I can think of off the top of my head: imagemagick and G’MIC, both of which have command line versions.

Using Linux terminal/MacOS terminal/Windows Powershell you can create a small script to run these programs for each of the steps you outline. Then you can run that script in a loop that acts on each file.

For example, on Linux …

for i in *.jpg ; do <script> "{i}" ; done

The must accept an argument that is the filename ( “${i}” in the for loop ).

Both MacOS and Windows Powershell have similar capability.

Or you can simply run each step of your process in successive loops, where, using G’MIC as an example …



do gmic [gmic params] “${i}”

where [gmic params] are

Using gmic to do this seems daunting, but you can determine the [gmic params] by using G’MIC from within GIMP. There is a G’MIC setting that will use the G’MIC procedure and its params to name the output layer from G’MIC use. Simply write the layer name down and you’ll have the G’MIC procedures & params you can use with the command line version of G’MIC.

Also, G’MIC uses blend modes for two images, so you’d first open image01, run highpass filter, save with new name image01HP, open image01 and blend with image01HP, save blended image, image01HPBlended, then delete image01HP. Yes, l there is a fair bit of I/O doing things this way, but the linear simplicity IMO more than offsets any time penalty to run the changes.

If it’s not already installed, you can download the CLI version of G’MIC from the GreyC web site.

There is scripting capability within GIMP but it’s based on a scripting technology called Scheme I find incomprehensible with all its bazillion parentheses. And you’d have to learn GIMP’s object model to identify files, layers, etc. IMO it’s much easier to use a terminal and a command line tool to do this kind of “actions on many files” work.


1 Like

Many thanks for the response and advice. Yeah GIMP seems a bit clunky for batch processing and automation.
I’m running Linux so I have many different graphics tools installed. Imagemagick and G’MIC are installed in addition.

I haven’t used G’MIC before but I use mogrify and convert from Imagemagick quite a bit. I’ll see if that has an HPF function, but if not I’ll have to do everything manually which will of course will take forever :frowning:

Hmm… just looking at a first link from a Google search for ImageMagick and I get this:

maybe promising! Will need to test and see the result first. Putting it into a shell script after that shouldn’t be too much of a problem.

If I’m honest, I find imagemagick more daunting than G’MIC. That I can get G’MIC params from testing inside GIMP where I can use the G’MIC ui seems to me the bonus in its use.

Best of luck to you!

In ImageMagick, a simple high-pass function is -sharpen. [EDIT: no, sorry, sharpen is high-boost, not high-pass.] So a command for the OP would be:

magick toes.png ( +clone -sharpen 0x3 ) -compose SoftLight -composite -quality 100 out.jpg

That can be put in a shell script to process all the files.


1 Like

I’m reading up on the command:

Will need to play with it and see if it works.

Right now my work flow is basically using 3 different software packages across 2 operating systems.

First using Topaz AI to denoise. I’m not using AI sharpen because I find the HPF has better results and doesn’t make things up so easier to control. Then I load the image into RawTherapee, again not sharpening the image using the Sharpening tool. Finally feeding into GIMP.

The type of result I’m looking for with the HPF is this before blending, I set the contrast to 2.5 and leave the radius at default value:

If you show the input file for that image, I’ll find an approximation with IM.

Grrr… I’m not able to upload the file, probably too large as it’s 124MB.

In this case I’ll do something different. This folder contains 2 shots of a squirrel:

The .DNG format file is soft while the .jpg file has been recovered. I used Hard Light to blend due to the softness of the original but again I kept the contrast setting at 2.5 which seems to work really well

Ok, so I changed your command to this:

magick file.tiff -sharpen 0x3 -quality 100 /tmp/out.jpg

and actually it seems to have the same effect. Just magnified up to 100% and can’t really see any difference. There maybe more differences in the long run but for the particular image that I tried it on, it seems to have done what I need (I think?)…

… and actually it seems to have the same effect

Yes, I have caused some confusion. Sorry about that. “-sharpen” boosts high frequencies, which is the overall effect from your sequence in the OP. One step in your sequence is a high-pass filter, which cuts low frequencies.

A high-pass filter can be made by subtracting a blur from its input. (A blur is a low-pass filter, so subtracting that reduces low frequencies, passing high frequencies.)

magick toes.png ( +clone -blur 0x3 ) -compose Mathematics -define compose:args=0,-1,1,0.5 -composite x.jpg

But I think your goal isn’t really a high-pass image, but a high-boost image, a sharpened image.

Precisely, I am looking for a sharpened image and the high pass filter method in GIMP was actually recommended to me by a fellow photographer who actually suggested to do it in Photoshop which I don’t have or use.

So if ImageMagick uses the same concept for sharpening then results should be similar or the same. I tried 0x3 and 0x4 values of sharpen on the Squirrel mentioned above. I couldn’t see much of a difference between what I achieved in GIMP.

If this is the case then I’ll put together a shell script to read a bunch of input files and output the sharpened versions.

I think each tools like DarkTable or RT’s sharpening work slightly differently so hopefully I’ll have the result I need with this method.

This is my original GIMP edit of the squirrel:

This one is using ImageMagick with value 0x4:

There are approximately one zillion ways to sharpen an image. I explore a small number of these using ImageMagick in:

Maximise local contrast
Adaptive blur and sharpen
Adaptive contour blur and sharpen
Integral images: sharpening

Going back to the original about Gimp and a Gimp answer. Gimp is probably not the way to go, but having a look at what is possible.

First snag: High Pass in Gimp 2.10 is a GEGL filter, not in the Gimp pdb, not normally scriptable. It can be made into a python plugin using a second python plugin.

Second snag: Looks to me that GEGL high-pass has a bug. The parameters are std-dev and contrast, while the Gimp GUI allows changing these parameters, however only the default is applied by command and that might not be enough sharpening for you.

Third snag: I am not a coder, simple python is my limit. Not all linux Gimp 2.10 comes with python support, although the flatpak version does. There are other ways to add gimp-python.

This as an example: A test of the plugin on a single image. Zoomed in you can just see a little sharpening, probably not enough.

Batch processing, Use the BIMP plugin. Add the python plugin you made. BIMP has a export-as function for jpeg.

If you can find a suitable gmic filter then apply it all your images using BIMP.
Where to get BIMP
BIMP. Batch Image Manipulation Plugin for GIMP. | Alessandro Francesconi and it is not difficult to compile for linux.
There is a dedicated flatpak BIMP
I keep a linux binary here, BIMP version 2.6

BIMP is slow ? Set it going and have a coffee or two.

I have BIMP installed but couldn’t find a way to do what I needed… you are probably correct that GIMP is not the ideal way to go batch process.

Right now I’m just writing a shell script for ImageMagick

Eventually I ended up with a script as below based on the advice given:

for i in `ls *.tif` 
  filename=`echo $i | cut -d'.' -f1`
  #echo $filename
  #[ ! -f jpg/$filename.jpg ] && echo $filename
  [ ! -f jpg/$filename.jpg ] && magick $filename.tif -sharpen 0x3 -quality 100 jpg/$filename.jpg

Just going through the images now and making sure that the sharpening is what I want, but so far all looks fine

Command line FTW. You can, in the future, do this on a single line at the terminal prompt (note this example uses command line substitution zsh mode, but bash can do the same thing with slightly altered syntax, see below):

$ for i in *.tif ; do [ ! -f ./jpg/“{i:s/.tif/.jpg/"}" ] && m agick "{i}” -sharpen 0x3 -quality 100 ./jpg/“${i:s/.tif/.jpg/}” ; done

The variable substitution for zsh uses the ubiquitous


Bash syntax is slightly different but quite similar, the s and final / are omitted:

$ for i in *.tif ; do [ ! -f ./jpg/“{$i/.tif/.jpg”}" ] && m

agick “{i}" -sharpen 0x3 -quality 100 ./jpg/"{i/.tif/.jpg}” ; done

I think [ ! -f x ] && works the same in both shells.

Thanks BTW for this question as I learned a lot about imagemagick!

1 Like

Here are the images that have been done using my script above, some of them have been processed using GIMP initially. I can’t see any discernible difference between the sharpening though:

It was actually a great experience because I bought a new lens for my camera so being able to bulk sharpen like this makes life a lot easier. Of course the lens itself is sharp but the extra bit of sharpening adds zest to the images and gives them an overall better clarity.

Try Gimp / Bimp?

I did but it didn’t work… it’s quite particular what I’m trying to achieve.

In fact I have paid Topaz AI sharpen but for subjects where the detail is lacking or partial I find the AI does a “best guess” and makes things up.

With high pass filtering, either from GIMP directly or any other software that uses the same technique, it basically adds contrast to edge lines that one can control creating a particular visual look.

Sure it’s not the only method but from what I’m aware of one of the most suitable for photography especially during bad light conditions or any other event that may make the subject a blurry, eg. wobbling with shake/vibration reduction not being able to keep up or cheap and poor quality lens