Example #1
0
def convert_image(target_dir, output_dir, image_name):
    '''
    Обрабатывает картинку.
    @param target_dir: string
    @param output_dir: string
    @param image_name: string
    '''
    output_path = os.path.join(output_dir, image_name)
    if os.path.exists(output_path):
        print '%s already exists, skipping'%image_name
        return
    image = pdb.file_jpeg_load(os.path.join(target_dir, image_name), image_name)
    layer = image.layers[0]
    # Выравниваем уровни:
    # pdb.gimp_levels_stretch(layer)
    # Добавляем нерезкую маску:
    # pdb.plug_in_unsharp_mask(image, layer, 5, 0.5, 0)
    # Изменяем размер картинки:
    width, height = get_image_new_dimensions(image)
    pdb.gimp_image_scale(image, width, height)
    # Автоматически увеличиваем контраст:
    pdb.plug_in_c_astretch(image, layer)
    # Повышаем резкость:
    pdb.plug_in_sharpen(image, layer, 50)
    pdb.gimp_file_save(image, layer, output_path, image_name)
    pdb.gimp_image_delete(image)