本文整理匯總了Python中pgmagick.api.Image.blur方法的典型用法代碼示例。如果您正苦於以下問題:Python Image.blur方法的具體用法?Python Image.blur怎麽用?Python Image.blur使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pgmagick.api.Image
的用法示例。
在下文中一共展示了Image.blur方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: ImageTestCase
# 需要導入模塊: from pgmagick.api import Image [as 別名]
# 或者: from pgmagick.api.Image import blur [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)
示例2: ImageTestCase
# 需要導入模塊: from pgmagick.api import Image [as 別名]
# 或者: from pgmagick.api.Image import blur [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)