rnd.seed(8)

imagewell = pb.loadImageWell(resultfile="imagewell-files")
tiles = imagewell['landscape']
rnd.shuffle(tiles)

img1path = tiles.pop()
img2path = tiles.pop()

# create the canvas
c = pb.canvas(int(WIDTH), int(HEIGHT))
c.fill((255, 255, 255))

imsize = int((WIDTH - 30) / 2)
x, y = 10, 10
img1, w1, h1 = pb.placeImage(c, img1path, x, y, imsize, "image1")
pb.label(c, "Original Image", x, y)

#
# flip horizontal
#
c.layers["image1"].duplicate()
c.top.name = "flip1"

x, y = w1 + 20, 10
c.top.translate(x, y)
c.top.flip(pb.HORIZONTAL)
pb.label(c, "Horizontal Flip", x, y)

#
# flip vertical
Example #2
0
img1path = tiles.pop()
img2path = tiles.pop()

# create a gray canvas
c = pb.canvas(WIDTH, HEIGHT)
c.fill((192, 192, 192))

#
# Image 1
#

_, filename = os.path.split(img1path)

#  create, scale and place the image
x, y = 10, 10
img1, w1, h1 = pb.placeImage(c, img1path, x, y, WIDTH - 20, "Image 1 Base")

c.top.autocontrast(cutoff=0)
pb.label(c, filename, x, y)

#
# Image 2
#
c.layers[img1].duplicate()

path = ((w1 / 2, 0), (w1, int(h1 * 0.667)), (w1 / 2.0, h1), (0, h1 * 0.75),
        (0, h1 / 2))
c.top.select(path)

x, y = 10, h1 + 20 + 10
c.top.translate(x, y)
# pick 2 images
img1path = tiles.pop()
img2path = tiles.pop()

# create a white canvas
c = pb.canvas(WIDTH, HEIGHT)
c.fill((192, 192, 192))

#
# Image 1
#

#  create, scale and place the image
x, y = 10, 10
top, w1, h1 = pb.placeImage(c, img1path, x, y, 256, "Image 1")
pb.label(c, "Image 1", x, y)

#
# Image 2
#
x, y = w1 + 20, 10
top, w2, h2 = pb.placeImage(c, img2path, x, y, 256, "Image 2")
pb.label(c, "Image 2", x, y)

#
# Color Images 1 & 2
#

h = max(h1, h2)
x, y = 10, h + 20
# pick 2 images
img1path = tiles.pop()
img2path = tiles.pop()

# create a white canvas
c = pb.canvas(WIDTH, HEIGHT)
c.fill((192, 192, 192))

#
# Image 1
#

_, fname = os.path.split(img1path)

#  create, scale and place the image
x, y = 10, 10
top, w1, h1 = pb.placeImage(c, img1path, x, y, 522, fname)
pb.label(c, fname, x, y)

#
# Image 2
#
x, y = 10, 10 + h1 + 10
top, w2, h2 = pb.placeImage(c, img1path, x, y, 522, fname)
c.layers[top].edge_enhance_more()

pb.label(c, "%s edge_enhance_more()" % fname, x, y)

# draw the result
c.draw(name="Layer_function_enhance_more")
Example #5
0
# pick 2 images
img1path = tiles.pop()
img2path = tiles.pop()

# create a white canvas
c = pb.canvas(WIDTH, HEIGHT)
c.fill((192, 192, 192))

#
# Image 1
#

#  create, scale and place the image
x, y = 10, 10
img1, w1, h1 = pb.placeImage(c, img1path, x, y, 256, "Image 1")
pb.label(c, "Image 1 Opacity: 100", x, y)

#
# Image 2
#
c.layers[img1].duplicate()
c.top.name = "Image 2"
c.top.opacity(80)

x, y = w1 + 20, 10
c.top.translate(x, y)
pb.label(c, "Image 2 Opacity: 80", x, y)

#
# Image 3
Example #6
0
img1path = tiles.pop()
img2path = tiles.pop()

# create a white canvas
c = pb.canvas(WIDTH, HEIGHT)
c.fill((192, 192, 192))

#
# Image 1
#

_, filename = os.path.split(img1path)

#  create, scale and place the image
x, y = 10, 10
img1, w1, h1 = pb.placeImage(c, img1path, x, y, 380, "Image 1 Base")

c.layers[img1].duplicate()
c.top.autocontrast(cutoff=0)
pb.label(c, "%s autocontrast: 0" % filename, x, y)

#
# Image 2
#
c.layers[img1].duplicate()
c.top.autocontrast(cutoff=5)

x, y = w1 + 20, 10
c.top.translate(x, y)
pb.label(c, "%s autocontrast: 5" % filename, x, y)
Example #7
0
rows = 3

enoughTiles = len(tiles) > (columns * 2 * rows)

randomblur = 0
randomflip = 0
paintoverlay = 0
gilb = 0

#
y_offset = HEIGHT / float(rows)
y_offset = int(round(y_offset))

# background image
bgimage = backgrounds.pop()
pb.placeImage(c, bgimage, 0, 0, WIDTH, "Image 1")
print("Background: %s" % bgimage.encode("utf-8"))

tilecounter = 0
for j in range(rows):
    colw = 0
    for i in range(columns):

        # new layer with a random image
        p = tiles.pop()
        tilecounter += 1
        if kwdbg or 1:
            print("%i  -- %s" % (tilecounter, p.encode("utf-8")))
        top = c.layer(p)

        # get current image bounds
Example #8
0
randomblur = 0
randomflip = 0
paintoverlay = 0
gilb = 0

picts = []
for t in range(columns * rows * 2):
    s = rnd.choice(tiles)
    picts.append(s)
    if 0:  #enoughTiles:
        tiles.remove(s)
# rnd.shuffle(picts)

# background image
bgimage = backgrounds.pop()
pb.placeImage(c, bgimage, 0, 0, WIDTH, "bgimage")
print("Background: %s" % bgimage.encode("utf-8"))

tilecounter = 0
for j in range(rows):
    for i in range(columns):

        # create image in canvas at 0,0
        nextpictpath = picts.pop()
        c.layer(nextpictpath)
        tilecounter += 1
        if kwdbg or 1:
            print("%i  -- %s" % (tilecounter, nextpictpath.encode("utf-8")))

        # add contrast
        c.top.contrast(1.1)
realheight = rowheight - 1*ygutter 

positions = list(grid(columns, rows, colwidth, rowheight, shuffled=True))

randomblur = not kwdbg
paintoverlay = 0 # not kwdbg
gilb = 0

#
# Base Image
#

#  create, scale and place the image
x, y = 0, 0
bgimage = backgrounds.pop()
top, w, h = pb.placeImage(c, bgimage, x, y, W, "Image 1")
print( "Background: %s" % bgimage.encode("utf-8") )

for position in positions:
    x, y = position

    # create image in canvas at 0,0
    p = tiles.pop()
    print(p.encode("utf-8"))
    top, w, h = pb.placeImage(c, p, 0, 0, maxsize=None, name="Image %i,%i" % (x,y)) #, width=False, height=True)

    # scale the layer to row height
    if rnd.random() > 0.5:
        # random row height 0.5 <= x <= 4.5
        tileheight = rowheight * (0.5 + rnd.random() * 3.0)
    else:
Example #10
0
# pick 2 images
img1path = tiles.pop()
img2path = tiles.pop()

# create a white canvas
c = pb.canvas(WIDTH, HEIGHT)
c.fill((192, 192, 192))

#
# Image 1
#

print(img1path.encode("utf-8"))
#  create, scale and place the image
x, y = 10, 10
top, w1, h1 = pb.placeImage(c, img1path, x, y, 512, "Image 1")
pb.label(c, "Image 1", x, y, 30)

x, y = 10, h1 + 10 + 10
top, w1, h1 = pb.placeImage(c, img1path, x, y, 512, "Image 1 colored")

# apply colorize

# c.top.colorize((192, 120, 0), (240, 255, 127))

c.top.colorize(black=(60, 60, 0), white=(250, 200, 96), mid=(220, 190, 16))

pb.label(c, "Image 1 colored", x, y, 30)

# draw the result
c.draw(name="Layer_function_colorize")
Example #11
0
realwidth = colwidth - 1 * xgutter
realheight = rowheight - 1 * ygutter

positions = list(grid(columns, rows, colwidth, rowheight))

randomblur = not kwdbg
paintoverlay = not kwdbg

#
# Base Image
#

#  create, scale and place the image
x, y = 0, 0
bgimage = backgrounds.pop()
top, w, h = pb.placeImage(c, bgimage, x, y, W, "Image 1")
print("Background: %s" % bgimage.encode("utf-8"))

for position in positions:
    x, y = position

    # create image in canvas at 0,0
    p = tiles.pop()
    print(p.encode("utf-8"))
    top, w, h = pb.placeImage(c,
                              p,
                              0,
                              0,
                              maxsize=None,
                              name="Image %i,%i" % (x, y))
Example #12
0
# pick 2 images
img1path = tiles.pop()
img2path = tiles.pop()

# create a gray canvas
c = pb.canvas(WIDTH, HEIGHT)
c.fill((192, 192, 192))

#
# Image 1
#

#  create, scale and place the image
x, y = 10, 10
top, w1, h1 = pb.placeImage(c, img1path, x, y, tilewidth, "Image 1")
pb.label(c, "Image 1", x, y)

#
# Image 2
#
x, y = w1 + 20, 10
top, w2, h2 = pb.placeImage(c, img2path, x, y, tilewidth, "Image 2")
pb.label(c, "Image 2", x, y)

#
# Overlay Images 1 & 2
#

h = max(h1, h2)
x, y = 10, h + 20
Example #13
0
# pick 2 images
img1path = tiles.pop()
img2path = tiles.pop()

# create a white canvas
c = pb.canvas( WIDTH, HEIGHT)
c.fill( (192, 192, 192) )


#
# Image 1
#

#  create, scale and place the image
x, y = 10, 10
_, w1, h1 = pb.placeImage(c, img1path, x, y, 192, "Image 1", width=True)
pb.label(c, "Image 1", x, y)

#
# Image 2
#
x, y = w1+20, 10
_, w2, h2 = pb.placeImage(c, img2path, x, y, 192, "Image 2", width=True)
pb.label(c, "Image 2", x, y)



#
# Mask Images 1 & 2
#
Example #14
0
    y0 = insetleft

    # fill a page
    c = pb.canvas(pagewidth, pageheight)
    c.fill((233, 233, 233))
    debugcanvas(c)

    pageitems = 0

    g = grid(columns, rows, cellwidth, cellheight, gutter)

    for x, y in g:
        x += x0
        y += y0
        x = int(round(x))
        y = int(round(y))
        try:
            img = tiles.pop(0)
            print((x, y, img.encode("utf-8")))
        except:
            done = True
            break
        folder, filename = os.path.split(img)
        pb.placeImage(c, img, 0, 0, cellwidth, filename)
        c.top.translate(x, y)
        pageitems += 1
    # pdb.set_trace()
    if pageitems > 0:
        c.draw(name=pagename)
        pagenr += 1