示例#1
0
def skew(image, offset, axis):
    if not axis:
        axis = axes.x

    if axis == axes.x:
        x_angle = degrees(atan(offset / image.height))
        y_angle = 0
    elif axis == axes.y:
        x_angle = 0
        y_angle = degrees(atan(offset / image.width))
    c_call(image, 'shear', from_string('transparent'), x_angle, y_angle)
示例#2
0
def splice(image, x, y, width, height):
    background = from_string('transparent')

    # preserve background color
    old_color = Color()

    c_call(image, ('get', 'background_color'), old_color)
    c_call(image, ('set', 'background_color'), background)

    c_call(image, 'splice', width, height, x, y)

    c_call(image, ('set', 'background_color'), old_color)
示例#3
0
def trim(image, similarity, background):
    # TODO: guessing of background?
    if not background:
        background = from_string('transparent')

    # preserve background color
    old_color = Color()

    c_call(image, ('get', 'background_color'), old_color)
    c_call(image, ('set', 'background_color'), background)

    c_call(image, 'trim', similarity * 000)

    c_call(image, ('set', 'background_color'), old_color)
示例#4
0
def wave(image, amplitude, length, offset, axis):
    if not axis:
        axis = axes.x

    transparent = from_string('transparent')

    # preserve background color
    old_color = Color()

    c_call(image, ('get', 'background_color'), old_color)
    c_call(image, ('set', 'background_color'), transparent)

    c_call(image, 'wave', amplitude, length)

    c_call(image, ('set', 'background_color'), old_color)
示例#5
0
from os.path import dirname, join

from pystacia import lena,  color

dest = join(dirname(__file__), '../_static/generated')

image = lena(128)
image.colorize(color.from_string('red'))
image.write(join(dest, 'lena_colorize_red.jpg'))
image.close()

image = lena(128)
image.colorize(color.from_string('yellow'))
image.write(join(dest, 'lena_colorize_yellow.jpg'))
image.close()

image = lena(128)
image.colorize(color.from_string('blue'))
image.write(join(dest, 'lena_colorize_blue.jpg'))
image.close()

image = lena(128)
image.colorize(color.from_string('violet'))
image.write(join(dest, 'lena_colorize_violet.jpg'))
image.close()
示例#6
0
from os.path import join, dirname

from pystacia import blank, color, checkerboard

dest = join(dirname(__file__), '../_static/generated')

image = blank(100, 100)
image.checkerboard()
image.write(join(dest, 'transparent.jpg'))
image.close()

image = blank(100, 100, color.from_string('red'))
image.write(join(dest, 'red.jpg'))
image.close()

image = blank(100, 100, color.from_rgba(0, 1, 0, 0.5))
image.checkerboard()
image.write(join(dest, 'green.jpg'))
image.close()

image = checkerboard(200, 200)
image.write(join(dest, 'checkerboard.png'))
image.close()
示例#7
0
def rotate(image, angle):
    c_call(image, 'rotate', from_string('transparent'), angle)
示例#8
0
from os.path import dirname, join

from pystacia import lena, color

dest = join(dirname(__file__), '../_static/generated')

image = lena(128)
image.colorize(color.from_string('red'))
image.write(join(dest, 'lena_colorize_red.jpg'))
image.close()

image = lena(128)
image.colorize(color.from_string('yellow'))
image.write(join(dest, 'lena_colorize_yellow.jpg'))
image.close()

image = lena(128)
image.colorize(color.from_string('blue'))
image.write(join(dest, 'lena_colorize_blue.jpg'))
image.close()

image = lena(128)
image.colorize(color.from_string('violet'))
image.write(join(dest, 'lena_colorize_violet.jpg'))
image.close()
示例#9
0
from os.path import join, dirname

from pystacia import blank, color, checkerboard

dest = join(dirname(__file__), "../_static/generated")

image = blank(100, 100)
image.checkerboard()
image.write(join(dest, "transparent.jpg"))
image.close()

image = blank(100, 100, color.from_string("red"))
image.write(join(dest, "red.jpg"))
image.close()

image = blank(100, 100, color.from_rgba(0, 1, 0, 0.5))
image.checkerboard()
image.write(join(dest, "green.jpg"))
image.close()

image = checkerboard(200, 200)
image.write(join(dest, "checkerboard.png"))
image.close()
示例#10
0
文件: fill.py 项目: ppawlak/pystacia
from os.path import join, dirname

from pystacia import lena, color

dest = join(dirname(__file__), '../_static/generated')

image = lena(128)
image.fill(color.from_string('red'))
image.write(join(dest, 'lena_fill_red.jpg'))
image.close()

image = lena(128)
image.fill(color.from_string('green'), 0.5)
image.write(join(dest, 'lena_fill_green.jpg'))
image.close()

image = lena(128)
image.fill(color.from_string('blue'), 0.25)
image.write(join(dest, 'lena_fill_blue.jpg'))
image.close()

image = lena(128)
image.fill(color.from_string('orange'), 0.2)
image.write(join(dest, 'lena_fill_orange.jpg'))
image.close()
示例#11
0
from os.path import join, dirname

from pystacia import lena, color

dest = join(dirname(__file__), '../_static/generated')

image = lena(128)
image.set_color(color.from_string('red'))
image.write(join(dest, 'lena_set_color_red.jpg'))
image.close()

image = lena(128)
image.set_color(color.from_rgba(0, 1, 0, 0.5))
image.checkerboard()
image.write(join(dest, 'lena_set_color_green.jpg'))
image.close()

image = lena(128)
image.set_color(color.from_rgba(0, 0, 0, 0.2))
image.checkerboard()
image.write(join(dest, 'lena_set_color_black.jpg'))
image.close()

image = lena(128)
image.set_color(color.from_rgba(1, 0, 1, 0.5))
image.checkerboard()
image.write(join(dest, 'lena_set_color_violet.jpg'))
image.close()