예제 #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')