Today at work I needed to create a few test images for debugging some image processing software. I needed to draw a few dark lines on a light background to check if the software will detect them correctly. I found out that Gimp can do this quite nicely for me.
import math
from gimpfu import *
rows = 640
cols = 480
def draw_vertical_lines(drawable,pixel,rows,cols,width):
for i in range(1,rows):
for j in range(1,cols,width):
pdb.gimp_drawable_set_pixel(drawable,i,j,3,pixel)
return
img = gimp.Image(cols,rows,RGB)
layer_one = gimp.Layer(img,"Layer1",cols,rows,RGB_IMAGE,100,NORMAL_MODE)
pdb.gimp_edit_fill(layer_one,BACKGROUND_FILL)
img.add_layer(layer_one,0)
pdb.gimp_edit_fill(layer_one,BACKGROUND_FILL)
gimp.Display(img)
pixel = [0.0,0.0,0.0,0.0]
draw_vertical_lines(layer_one, pixel, rows, cols, 25)