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)
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')
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')
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')
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')
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)
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')
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")
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")
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')
def test_half_dragon(ctx): img = get_image('dragon.gif') img = img.resized(img.size * 0.5) ctx.compare(img, 'half_dragon.miff')
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')
def test_half_dragon(ctx): img = get_image("dragon.gif") img = img.resized(img.size * 0.5) ctx.compare(img, "half_dragon.miff")
def test_half_terminal(ctx): img = get_image('terminal.gif') img = img.resized(img.size * 0.5) ctx.compare(img, 'half_terminal.miff')
def test_pixel_terminal(ctx): img = get_image('terminal.gif') img = img.resized(img.size.fit_area(4096)) ctx.compare(img, 'pixel_terminal.miff')
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')
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')
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')
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")
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')
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")
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')
def test_exact_dragon(ctx): img = get_image("dragon.gif") img = img.resized((64, 64)) ctx.compare(img, "exact_dragon.miff")
def test_pixel_dragon(ctx): img = get_image('dragon.gif') img = img.resized(img.size.fit_area(4096)) ctx.compare(img, 'pixel_dragon.miff')
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")
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')
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')
def test_half_terminal(ctx): img = get_image("terminal.gif") img = img.resized(img.size * 0.5) ctx.compare(img, "half_terminal.miff")
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')
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")
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')
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")
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')
def test_exact_terminal(ctx): img = get_image("terminal.gif") img = img.resized((64, 64)) ctx.compare(img, "exact_terminal.miff")
def test_exact_dragon(ctx): img = get_image('dragon.gif') img = img.resized((64, 64)) ctx.compare(img, 'exact_dragon.miff')
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")
def test_exact_terminal(ctx): img = get_image('terminal.gif') img = img.resized((64, 64)) ctx.compare(img, 'exact_terminal.miff')
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")
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')
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")
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')