Exemplo n.º 1
0
def effects():
    img = magick.image('testimages/original.jpg')
    new = magick.blur(img,3,1.5)
    new = magick.blur('testimages/original.jpg',3,1.5)  #also works
    new = magick.rotate(img,20)
    new = img.copy()
    new.contrast(10)
    out = magick.border(img,6,6,bordercolor='red')
    out = magick.charcoal(img,1,0.5)
    out = magick.colorize(img, 'red', 0.30)
Exemplo n.º 2
0
def draw_bar():
    data = [('red',30),('blue',80),('green',60)]
    img = magick.image('xc:white',size='100x150')
    dc = magick.newdc()
    dc.stroke = 'black'
    dc.stroke_width = 1
    left = 10
    bottom = 90
    size = 20
    for color,height in data:
        dc.fill = color
        dc.rect(left,bottom,left+size,bottom-height)
        img.draw(dc)
        left += size+2
    return img;
Exemplo n.º 3
0
def draw_shapes():
    img = magick.image('xc:#ffffffff',size='150x100')  # 'xc:transparent' should also work
    dc = magick.newdc()   # new "Drawing context with ImageMagick defaults"
    #dc.text(10,10,'some drawings ...')
    #img.draw(dc)
    dc.stroke='blue'
    dc.fill='none'
    dc.stroke_width = 3
    dc.circle(50,50,10) # radius of 10
    img.draw(dc)  # draw the primitives and clear them (keeps the state)
    dc.stroke='red'
    dc.rect(140,90,110,60)
    dc.line(110,60,125,40)
    dc.line(140,60,125,40)
    img.draw(dc)
    coords = [[10,90],[120,90],[70,20],[140,10]]  # can also be 1-D
    dc.bezier(coords)
    dc.stroke='green'
    img.draw(dc)
    return img
Exemplo n.º 4
0
def createFrame(val):
    val2 = 2.0*pi*val/360
    radius = 26
    x = cos(val2)*radius
    y = sin(val2)*radius
    # uses the savespace property of Numeric arrays to be sure
    #   that the output of multiplication by maxRGB stays the same type.
    #   MaxRGB is actually a rank-0 Numeric savespace array of the
    #   quantum type. 
    img = magick.image(Numeric.ones((60,60,3)) * magick.MaxRGB)
    dc = magick.newdc()
    dc.fill = 'white'
    dc.stroke = 'red'
    dc.stroke_width = 3
    dc.circle(30,30,radius)
    img.draw(dc)
    dc.stroke = 'blue'
    dc.line(30,30,30+x,30+y)
    img.draw(dc)
    return img
Exemplo n.º 5
0
def animate2():
    images = magick.image(*[createFrame(x) for x in range(0,360,10)])
    images.write('clock.gif')
    return images
Exemplo n.º 6
0
def animate1():
    img = magick.scale('testimages/original.jpg',(100,-1))
    img2 = magick.blur(img, 5, 1.5)
    imgs = magick.image(img, img2)
    imgs.write('ani1.gif')
    return 
Exemplo n.º 7
0
def composition():
    img = magick.image('testimages/original.jpg')
    small = magick.minify(img)
    small.opacity = 0.3 * magick.iMaxRGB
    img.composite(small, 5, 5, 'over')
    return img
Exemplo n.º 8
0
def load_save():
    img = magick.image('logo:')
    img.write('newfile.png')
    img.filename='anotherway.png'
    img.write()