L
L
Lici2012-10-29 00:50:14
linux
Lici, 2012-10-29 00:50:14

Batch Auto-Enhance GIMP Images

There is a folder with pictures (photos), several hundred.

There is such a thing in GIMP, Color - Levels - Auto. After that, the picture becomes more beautiful.

Question: how can I do this for all hundreds of pictures at once?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
P
Pavel Tyslyatsky, 2012-10-29
@tbicr

Gimp has built-in scripting languages ​​such as Scheme (Filters>Script-Fu>Console) and Python (Filters>Python-Fu>Console). Since Python is closer to me, I’ll tell you about it:
1) documentation
2) you can open the Filters>Python-Fu>Console console in the gimp itself and play around with the commands (especially see the Browse button)
3) A small example of using the script: it was necessary to create many of the same type icon markers by simply adding the icon to the background:

import os

ORIGINAL_IMAGES_IN_PATH = '../img/icons'

MARKER_IMAGES_OUT_PATH = '../img/markers'
MARKER_TEMPLATE_PATH = '../css/img-base/marker-template.png'

script = '''
import os

images_in_path = '%(images_in_path)s'

markers_out_path = '%(markers_out_path)s'
marker_template_file = '%(marker_template_file)s'

image_extension = '.png'

image_filter = lambda file_name: file_name[-len(image_extension):] == image_extension


for root, dirs, files in os.walk(images_in_path):
    for file in filter(image_filter, files):
        input_path = os.path.join(root, file)
        output_path = os.path.join(markers_out_path, file)

        image = pdb.gimp_file_load(marker_template_file, 'template')
        layer = pdb.gimp_file_load_layer(image, input_path)
        image.add_layer(layer, 0)
        layer.scale(23, 23, 0)
        layer.set_offsets(7, 7)
        merged_layer = image.merge_visible_layers(0)
        pdb.file_png_save2(image, merged_layer, output_path, output_path, 0, 9, 0, 0, 0, 0, 0, 0, 0)


pdb.gimp_quit(0)
''' % {'images_in_path': os.path.abspath(ORIGINAL_IMAGES_IN_PATH),
       'markers_out_path': os.path.abspath(MARKER_IMAGES_OUT_PATH),
       'marker_template_file': os.path.abspath(MARKER_TEMPLATE_PATH),}

os.system("""gimp --no-interface --batch-interpreter python-fu-eval --batch "%s" """ % script)

4) it looks like you need the gimp-levels-stretch command
Automatically modifies intensity levels in the specified drawable.
This procedure allows intensity levels in the specified drawable to be remapped according to a set of guessed parameters. It is equivalent to clicking the "Auto" button in the Levels tool. This procedure is only valid on RGB color and grayscale images. It will not operate on indexed drawables.

O
oleksandr_veles, 2012-10-29
@oleksandr_veles

You might want to use -normalize from imagemagick, something like this:
for i in *.jpg; do convert -normalize $i res_`basename $i jpg`jpg; done

N
Nikolai Vasilchuk, 2012-10-29
@Anonym

BIMP

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question