示例#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)
示例#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)
示例#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')
示例#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')
示例#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')
示例#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')
示例#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)
示例#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)
示例#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')
示例#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")
示例#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")
示例#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')
示例#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')
示例#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')
示例#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')
示例#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")
示例#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')
示例#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')
示例#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')
示例#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')
示例#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')
示例#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')
示例#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")
示例#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')
示例#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")
示例#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')
示例#27
0
def test_exact_dragon(ctx):
    img = get_image("dragon.gif")
    img = img.resized((64, 64))
    ctx.compare(img, "exact_dragon.miff")
示例#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')
示例#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")
示例#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')
示例#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')
示例#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")
示例#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')
示例#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")
示例#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')
示例#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")
示例#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')
示例#38
0
def test_exact_terminal(ctx):
    img = get_image("terminal.gif")
    img = img.resized((64, 64))
    ctx.compare(img, "exact_terminal.miff")
示例#39
0
def test_exact_dragon(ctx):
    img = get_image('dragon.gif')
    img = img.resized((64, 64))
    ctx.compare(img, 'exact_dragon.miff')
示例#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")
示例#41
0
def test_exact_terminal(ctx):
    img = get_image('terminal.gif')
    img = img.resized((64, 64))
    ctx.compare(img, 'exact_terminal.miff')
示例#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")
示例#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')
示例#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")
示例#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')