Exemplo n.º 1
0
def test_multi_frame_resize():
    """ImageMagick doesn't handle resizing correctly when a virtual canvas is
    involved.  Make sure we fixed it.
    """

    img = get_image('anim_bgnd.gif')

    # Original dimensions
    assert img.size == Size(100, 100)
    assert img[0].size == Size(32, 32)
    assert img[0].canvas.position == Vector(5, 10)
    assert img[1].size == Size(32, 32)
    assert img[1].canvas.position == Vector(35, 30)
    assert img[2].size == Size(32, 32)
    assert img[2].canvas.position == Vector(62, 50)
    assert img[3].size == Size(32, 32)
    assert img[3].canvas.position == Vector(10, 55)

    img = img.resized(img.size * 0.5)

    # Resized dimensions -- reduced by half
    assert img.size == Size(50, 50)
    assert img[0].size == Size(16, 16)
    assert img[0].canvas.position == Vector(3, 5)
    assert img[1].size == Size(16, 16)
    assert img[1].canvas.position == Vector(18, 15)
    assert img[2].size == Size(16, 16)
    assert img[2].canvas.position == Vector(31, 25)
    assert img[3].size == Size(16, 16)
    assert img[3].canvas.position == Vector(5, 28)
Exemplo n.º 2
0
def test_multi_frame_resize():
    """ImageMagick doesn't handle resizing correctly when a virtual canvas is
    involved.  Make sure we fixed it.
    """

    img = get_image('anim_bgnd.gif')

    # Original dimensions
    assert img.size == Size(100, 100)
    assert img[0].size == Size(32, 32)
    assert img[0].canvas.position == Vector(5, 10)
    assert img[1].size == Size(32, 32)
    assert img[1].canvas.position == Vector(35, 30)
    assert img[2].size == Size(32, 32)
    assert img[2].canvas.position == Vector(62, 50)
    assert img[3].size == Size(32, 32)
    assert img[3].canvas.position == Vector(10, 55)

    img = img.resized(img.size * 0.5)

    # Resized dimensions -- reduced by half
    assert img.size == Size(50, 50)
    assert img[0].size == Size(16, 16)
    assert img[0].canvas.position == Vector(3, 5)
    assert img[1].size == Size(16, 16)
    assert img[1].canvas.position == Vector(18, 15)
    assert img[2].size == Size(16, 16)
    assert img[2].canvas.position == Vector(31, 25)
    assert img[3].size == Size(16, 16)
    assert img[3].canvas.position == Vector(5, 28)
Exemplo n.º 3
0
def test_color_fx_math(ctx):
    gold = RGBColor.parse('gold')
    def gold_filter(self, *a):
        return gold * 0.7

    img = get_image('test.png')
    img[0].translucent = False
    img = evaluate(gold_filter, *img)
    ctx.compare(img, 'color_fx_math.miff')
Exemplo n.º 4
0
def test_color_fx_constant(ctx):
    gold = RGBColor.parse('gold')

    def gold_filter(self, *a):
        return gold

    img = get_image('test.png')
    img[0].translucent = False
    img = evaluate(gold_filter, *img)
    ctx.compare(img, 'color_fx_constant.miff')
Exemplo n.º 5
0
def test_color_fx_constant(ctx):
    gold = RGBColor.parse('gold')

    @image_filter
    def gold_filter(self, *a):
        return gold

    img = get_image('test.png')
    img[0].translucent = False
    img = gold_filter(*img)
    ctx.compare(img, 'color_fx_constant.miff')
Exemplo n.º 6
0
def test_color_fx_math(ctx):
    gold = RGBColor.parse('gold')

    @image_filter
    def gold_filter(self, *a):
        return gold * 0.7

    img = get_image('test.png')
    img[0].translucent = False
    img = gold_filter(*img)
    ctx.compare(img, 'color_fx_math.miff')
Exemplo n.º 7
0
def test_multi_frame_crop_repage():
    """ImageMagick's usual crop-plus-repage dance (which we emulate) doesn't
    quite work with multi-frame images, so we do slightly more clever math.
    """

    img = get_image('anim_bgnd.gif')

    # Original dimensions
    check_original_dimensions(img)

    canvas = Rectangle(0, 0, *img.size)
    img = img.cropped(canvas)

    # "Cropped" dimensions -- exactly the same
    check_original_dimensions(img)
Exemplo n.º 8
0
def test_multi_frame_crop_repage():
    """ImageMagick's usual crop-plus-repage dance (which we emulate) doesn't
    quite work with multi-frame images, so we do slightly more clever math.
    """

    img = get_image('anim_bgnd.gif')

    # Original dimensions
    check_original_dimensions(img)

    canvas = Rectangle(0, 0, *img.size)
    img = img.cropped(canvas)

    # "Cropped" dimensions -- exactly the same
    check_original_dimensions(img)
Exemplo n.º 9
0
def test_color_colorize(ctx):
    img = get_image('test.png')
    img[0].translucent = False
    img = Colorize(RGBColor.parse('sienna'), 1.0)(*img)
    ctx.compare(img, 'color_colorize.miff')
Exemplo n.º 10
0
def test_fill_crop_dragon(ctx):
    img = get_image("dragon.gif")
    img = img.resized(img.size.fit_around((64, 64)))
    # XXX extent???
    ctx.compare(img, "fill_crop_dragon.miff")
Exemplo n.º 11
0
def test_embiggen_dragon(ctx):
    img = get_image("dragon.gif")
    img = img.resized(img.size.fit_inside((64, 64), downscale=False))
    ctx.compare(img, "embiggen_dragon.miff")
Exemplo n.º 12
0
def test_read_terminal(ctx):
    img = get_image('terminal.gif')
    img = img.resized(img.size.fit_inside((64, 64)))
    ctx.compare(img, 'read_terminal.miff')
Exemplo n.º 13
0
def test_half_dragon(ctx):
    img = get_image('dragon.gif')
    img = img.resized(img.size * 0.5)
    ctx.compare(img, 'half_dragon.miff')
Exemplo n.º 14
0
def test_half_dragon(ctx):
    img = get_image('dragon.gif')
    img = img.resized(img.size * 0.5)
    ctx.compare(img, 'half_dragon.miff')
Exemplo n.º 15
0
def test_fill_crop_dragon(ctx):
    img = get_image('dragon.gif')
    img = img.resized(img.size.fit_around((64, 64)))
    # XXX extent???
    ctx.compare(img, 'fill_crop_dragon.miff')
Exemplo n.º 16
0
def test_half_dragon(ctx):
    img = get_image("dragon.gif")
    img = img.resized(img.size * 0.5)
    ctx.compare(img, "half_dragon.miff")
Exemplo n.º 17
0
def test_half_terminal(ctx):
    img = get_image('terminal.gif')
    img = img.resized(img.size * 0.5)
    ctx.compare(img, 'half_terminal.miff')
Exemplo n.º 18
0
def test_pixel_terminal(ctx):
    img = get_image('terminal.gif')
    img = img.resized(img.size.fit_area(4096))
    ctx.compare(img, 'pixel_terminal.miff')
Exemplo n.º 19
0
def test_color_colorize(ctx):
    img = get_image('test.png')
    img[0].translucent = False
    img = Colorize(RGBColor.parse('sienna'), 1.0)(*img)
    ctx.compare(img, 'color_colorize.miff')
Exemplo n.º 20
0
def test_fill_terminal(ctx):
    img = get_image('terminal.gif')
    img = img.resized(img.size.fit_around((64, 64)))
    ctx.compare(img, 'fill_terminal.miff')
Exemplo n.º 21
0
def test_fill_dragon(ctx):
    img = get_image('dragon.gif')
    img = img.resized(img.size.fit_around((64, 64)))
    ctx.compare(img, 'fill_dragon.miff')
Exemplo n.º 22
0
def test_embiggen_dragon(ctx):
    img = get_image('dragon.gif')
    img = img.resized(img.size.fit_inside((64, 64), downscale=False))
    ctx.compare(img, 'embiggen_dragon.miff')
Exemplo n.º 23
0
def test_pixel_dragon(ctx):
    img = get_image("dragon.gif")
    img = img.resized(img.size.fit_area(4096, emulate=True))
    ctx.compare(img, "pixel_dragon.miff")
Exemplo n.º 24
0
def test_embiggen_terminal(ctx):
    img = get_image('terminal.gif')
    img = img.resized(img.size.fit_inside((64, 64), downscale=False))
    ctx.compare(img, 'embiggen_terminal.miff')
Exemplo n.º 25
0
def test_resize_dragon(ctx):
    img = get_image("dragon.gif")
    img = img.resized(img.size.fit_inside((64, 64)))
    ctx.compare(img, "resize_dragon.miff")
Exemplo n.º 26
0
def test_fill_crop_terminal(ctx):
    img = get_image('terminal.gif')
    img = img.resized(img.size.fit_around((64, 64)))
    # XXX extent???
    ctx.compare(img, 'fill_crop_terminal.miff')
Exemplo n.º 27
0
def test_exact_dragon(ctx):
    img = get_image("dragon.gif")
    img = img.resized((64, 64))
    ctx.compare(img, "exact_dragon.miff")
Exemplo n.º 28
0
def test_pixel_dragon(ctx):
    img = get_image('dragon.gif')
    img = img.resized(img.size.fit_area(4096))
    ctx.compare(img, 'pixel_dragon.miff')
Exemplo n.º 29
0
def test_shrink_dragon(ctx):
    img = get_image("dragon.gif")
    img = img.resized(img.size.fit_inside((64, 64), upscale=False))
    ctx.compare(img, "shrink_dragon.miff")
Exemplo n.º 30
0
def test_pixel_dragon(ctx):
    img = get_image('dragon.gif')
    img = img.resized(img.size.fit_area(4096, emulate=True))
    ctx.compare(img, 'pixel_dragon.miff')
Exemplo n.º 31
0
def test_read_dragon(ctx):
    img = get_image('dragon.gif')
    img = img.resized(img.size.fit_inside((64, 64)))
    ctx.compare(img, 'read_dragon.miff')
Exemplo n.º 32
0
def test_half_terminal(ctx):
    img = get_image("terminal.gif")
    img = img.resized(img.size * 0.5)
    ctx.compare(img, "half_terminal.miff")
Exemplo n.º 33
0
def test_pixel_terminal(ctx):
    img = get_image('terminal.gif')
    img = img.resized(img.size.fit_area(4096, emulate=True))
    ctx.compare(img, 'pixel_terminal.miff')
Exemplo n.º 34
0
def test_pixel_terminal(ctx):
    img = get_image("terminal.gif")
    img = img.resized(img.size.fit_area(4096, emulate=True))
    ctx.compare(img, "pixel_terminal.miff")
Exemplo n.º 35
0
def test_resize_dragon(ctx):
    img = get_image('dragon.gif')
    img = img.resized(img.size.fit_inside((64, 64)))
    ctx.compare(img, 'resize_dragon.miff')
Exemplo n.º 36
0
def test_resize_terminal(ctx):
    img = get_image("terminal.gif")
    img = img.resized(img.size.fit_inside((64, 64)))
    ctx.compare(img, "resize_terminal.miff")
Exemplo n.º 37
0
def test_resize_terminal(ctx):
    img = get_image('terminal.gif')
    img = img.resized(img.size.fit_inside((64, 64)))
    ctx.compare(img, 'resize_terminal.miff')
Exemplo n.º 38
0
def test_exact_terminal(ctx):
    img = get_image("terminal.gif")
    img = img.resized((64, 64))
    ctx.compare(img, "exact_terminal.miff")
Exemplo n.º 39
0
def test_exact_dragon(ctx):
    img = get_image('dragon.gif')
    img = img.resized((64, 64))
    ctx.compare(img, 'exact_dragon.miff')
Exemplo n.º 40
0
def test_shrink_terminal(ctx):
    img = get_image("terminal.gif")
    img = img.resized(img.size.fit_inside((64, 64), upscale=False))
    ctx.compare(img, "shrink_terminal.miff")
Exemplo n.º 41
0
def test_exact_terminal(ctx):
    img = get_image('terminal.gif')
    img = img.resized((64, 64))
    ctx.compare(img, 'exact_terminal.miff')
Exemplo n.º 42
0
def test_embiggen_terminal(ctx):
    img = get_image("terminal.gif")
    img = img.resized(img.size.fit_inside((64, 64), downscale=False))
    ctx.compare(img, "embiggen_terminal.miff")
Exemplo n.º 43
0
def test_shrink_dragon(ctx):
    img = get_image('dragon.gif')
    img = img.resized(img.size.fit_inside((64, 64), upscale=False))
    ctx.compare(img, 'shrink_dragon.miff')
Exemplo n.º 44
0
def test_fill_crop_terminal(ctx):
    img = get_image("terminal.gif")
    img = img.resized(img.size.fit_around((64, 64)))
    # XXX extent???
    ctx.compare(img, "fill_crop_terminal.miff")
Exemplo n.º 45
0
def test_shrink_terminal(ctx):
    img = get_image('terminal.gif')
    img = img.resized(img.size.fit_inside((64, 64), upscale=False))
    ctx.compare(img, 'shrink_terminal.miff')