当前位置: 首页>>代码示例>>Python>>正文


Python Image.blur_channel方法代码示例

本文整理汇总了Python中pgmagick.api.Image.blur_channel方法的典型用法代码示例。如果您正苦于以下问题:Python Image.blur_channel方法的具体用法?Python Image.blur_channel怎么用?Python Image.blur_channel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pgmagick.api.Image的用法示例。


在下文中一共展示了Image.blur_channel方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: ImageTestCase

# 需要导入模块: from pgmagick.api import Image [as 别名]
# 或者: from pgmagick.api.Image import blur_channel [as 别名]
class ImageTestCase(unittest.TestCase):

    def setUp(self):
        self.img = Image((600, 400), 'red')

    def test_unicodefilename(self):
        self.img.write('unicode.png')
        if sys.version_info >= (3, ):
            img = Image('unicode.png')
        else:
            img = Image(unicode('unicode.png'))
        img.scale(0.5)
        if sys.version_info >= (3, ):
            img.write('unicode.jpg')
        else:
            img.write(unicode('unicode.jpg'))

    def test_nonarg(self):
        im = Image()

    def test_arg(self):
        im = Image((600, 400), 'red')

    def test_arg_float(self):
        im = Image((600.5, 400.4), 'red')

    def test_blur(self):
        self.img.blur(2, 2.3)
        self.img.write('t.jpg')

    def test_blur_channel(self):
        self.img.blur_channel('cyan')
        self.img.write('t.jpg')

    def test_scale(self):
        im = Image((600, 400), 'red')
        im.scale(0.6)
        im.write('t.jpg')

    def test_composite_arg_list(self):
        base = Image((300, 200), 'green')
        layer = Image((300, 200), 'transparent')
        drawer = Draw()
        drawer.circle(50, 50, 50, 100)
        layer.draw(drawer)
        base.composite(layer, (10, 10), 'over')
        base.write('t.png')

    def test_composite_arg_gravity(self):
        base = Image((300, 200), 'green')
        layer = Image((150, 100), 'transparent')
        drawer = Draw()
        drawer.circle(50, 50, 20, 20)
        layer.draw(drawer)
        base.composite(layer, 'center', 'over')
        base.write('t.png')

    def test_crop(self):
        img = Image((300, 200), 'gradient:#ffff00-#00ffff')
        img.crop(20, 20, 50, 100)
        img.write('t.png')

    def test_fontpointsize(self):
        img = Image((300, 200), 'red')
        img.font_pointsize(60)
        self.assertEqual(60, img.font_pointsize())
        self.assertEqual(float, type(img.font_pointsize()))
        img.annotate("hello", (100, 100))
        img.write('t.png')

    def test_size_property(self):
        im = Image((500, 300), 'red')
        self.assertEqual(im.width, 500)
        self.assertEqual(im.height, 300)
        im.scale(0.5)
        self.assertEqual(im.width, 250)
        self.assertEqual(im.height, 150)
开发者ID:suoinguon,项目名称:pgmagick,代码行数:79,代码来源:test_pgmagick_api.py

示例2: ImageTestCase

# 需要导入模块: from pgmagick.api import Image [as 别名]
# 或者: from pgmagick.api.Image import blur_channel [as 别名]
class ImageTestCase(unittest.TestCase):

    def setUp(self):
        self.img = Image((600, 400), 'red')

    def test_unicodefilename(self):
        self.img.write('unicode.png')
        img = Image(u'unicode.png')
        img.scale(0.5)
        img.write(u'unicode.jpg')

    def test_nonarg(self):
        Image()

    def test_arg(self):
        Image((600, 400), 'red')

    def test_arg_float(self):
        Image((600.5, 400.4), 'red')

    def test_blur(self):
        self.img.blur(2, 2.3)
        self.img.write('t.jpg')

    def test_blur_channel(self):
        self.img.blur_channel('cyan')
        self.img.write('t.jpg')

    def test_scale(self):
        img = Image((600, 400), 'gradient:#ffffff-#000000')
        img.scale(0.6)
        img.write('t.jpg')

    def test_scale_with_filtertype(self):
        img = Image((600, 400), 'gradient:#ffffff-#000000')
        img.scale(0.6, 'Catrom')
        img.write('t.jpg')
        m = hashlib.md5()
        with open('t.jpg', 'rb') as fp:
            m.update(fp.read())
            scale_with_filtertype_catrom_digest = m.hexdigest()
        img = Image((600, 400), 'gradient:#ffffff-#000000')
        img.scale(0.6, 'Cubic')
        img.write('t.jpg')
        m = hashlib.md5()
        with open('t.jpg', 'rb') as fp:
            m.update(fp.read())
            scale_with_filtertype_cubic_digest = m.hexdigest()
        img = Image((600, 400), 'gradient:#ffffff-#000000')
        img.scale(0.6)
        img.write('t.jpg')
        m = hashlib.md5()
        with open('t.jpg', 'rb') as fp:
            m.update(fp.read())
            scale_digest = m.hexdigest()
        self.assertNotEqual(scale_with_filtertype_catrom_digest, scale_digest)
        self.assertNotEqual(scale_with_filtertype_catrom_digest, scale_with_filtertype_cubic_digest)

    def test_composite_arg_list(self):
        base = Image((300, 200), 'green')
        layer = Image((300, 200), 'transparent')
        drawer = Draw()
        drawer.circle(50, 50, 50, 100)
        layer.draw(drawer)
        base.composite(layer, (10, 10), 'over')
        base.write('t.png')

    def test_composite_arg_gravity(self):
        base = Image((300, 200), 'green')
        layer = Image((150, 100), 'transparent')
        drawer = Draw()
        drawer.circle(50, 50, 20, 20)
        layer.draw(drawer)
        base.composite(layer, 'center', 'over')
        base.write('t.png')

    def test_crop(self):
        img = Image((300, 200), 'gradient:#ffff00-#00ffff')
        img.crop(20, 20, 50, 100)
        img.write('t.png')

    def test_fontpointsize(self):
        img = Image((300, 200), 'red')
        img.font_pointsize(60)
        self.assertEqual(60, img.font_pointsize())
        self.assertEqual(float, type(img.font_pointsize()))
        if sys.platform.lower() == 'darwin':
            img.font("/Library/Fonts/Arial.ttf")
        img.annotate("hello", (100, 100))
        img.write('t.png')

    def test_size_property(self):
        img = Image((500, 300), 'red')
        self.assertEqual(img.width, 500)
        self.assertEqual(img.height, 300)
        img.scale(0.5)
        self.assertEqual(img.width, 250)
        self.assertEqual(img.height, 150)
开发者ID:hhatto,项目名称:pgmagick,代码行数:100,代码来源:test_pgmagick_api.py


注:本文中的pgmagick.api.Image.blur_channel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。