Скрипт для создания рамки фотографии (GIMP+Python)
Часто приходиться добавлять рамку к фотографиям перед печатью. Фотография до применения скрипта

и после применения:
Скопируйте скрипт в файл 'frame.py' и положите файл в папку '/usr/share/gimp/2.0/plug-ins' или в '~/.gimp/plug-ins', установите файлу разрешение на выполнение, и в меню Python-fu/Decor/Border вы сможете выполнить скрипт. (Следует отметить что скрипт не тестировался на Windows системах!!!)
#!/usr/bin/env python # Gimp-Python - allows the writing of Gimp plugins in Python. # Copyright (C) 1997 James Henstridge <james@daa.com.au> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. from gimpfu import * def PythonFrame(image, layer, \ median_color, \ outer_width, outer_color): def CreateFrame(name, width, color): image_width = pdb.gimp_image_width(image) image_height = pdb.gimp_image_height(image) # get a copy of background background_copy = pdb.gimp_image_get_active_layer (image) border = pdb.gimp_layer_copy(background_copy,0) pdb.gimp_image_add_layer(image, border, -1) #select and make stroke pdb.gimp_rect_select(image, outer_width, outer_width, image_width - 2*outer_width , image_height - 2*outer_width , CHANNEL_OP_REPLACE, 0, 0.0) pdb.gimp_context_set_foreground(median_color) drawable = pdb.gimp_image_active_drawable (image) # TODO somehow set the width for the stroke pdb.gimp_edit_stroke(drawable) # fill by foreground color pdb.gimp_selection_invert(image) pdb.gimp_context_set_foreground(outer_color) drawable = pdb.gimp_image_active_drawable (image) pdb.gimp_bucket_fill(drawable,FG_BUCKET_FILL,NORMAL_MODE,100,0,0,outer_width/2,outer_width/2) pdb.gimp_layer_set_opacity(border,50) pdb.gimp_selection_none (image) # megre visible layers pdb.gimp_image_merge_visible_layers(image,EXPAND_AS_NECESSARY) image.undo_group_start() CreateFrame('Frame Border', outer_width, outer_color) image.undo_group_end() register( "python_fu_borders", "Add frame to the image", "Add frame to the image", "Alexander Darovsky & Dmytro Golub", "Alexander Darovsky & Dmytro Golub", "2006-2008", "<Image>/Python-Fu/Decor/_Borders", "RGB*", [ (PF_COLOR, "median_color", "Median Frame Color", (255,255,255)), (PF_INT, "outer_width", "Outer Frame Width", 20), (PF_COLOR, "outer_color", "Outer Frame Color", ( 0, 0, 0)), ], [], PythonFrame) main()
Из недостатков которые необходимо устранить стоит отметить, что пока нет возможности указать ширину 'Median Frame'. Это существенный недостаток, т.к сейчас это приходиться делать вручную. Выделите произвольную область на фотографии, затем 'Edit'->'Stroke selection' и установите 'Line Width' в необходимую ширину, после этого скрипт будет использовать установленную ширину для операции 'Stroke selection'. Со временем я постараюсь устранить этот недостаток.
Ссылки по теме:
Про скрипты в GIMP
