本文整理匯總了Python中django.utils.image.Image.new方法的典型用法代碼示例。如果您正苦於以下問題:Python Image.new方法的具體用法?Python Image.new怎麽用?Python Image.new使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類django.utils.image.Image
的用法示例。
在下文中一共展示了Image.new方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: create_imagefile
# 需要導入模塊: from django.utils.image import Image [as 別名]
# 或者: from django.utils.image.Image import new [as 別名]
def create_imagefile(self):
"""Creates a PNG image with StringIO"""
img = Image.new("RGBA", size=(200, 200), color=(255, 0, 0, 0))
file_object = StringIO.StringIO()
img.save(file_object, 'png')
file_object.seek(0)
return file_object
示例2: test_signal_catches_create
# 需要導入模塊: from django.utils.image import Image [as 別名]
# 或者: from django.utils.image.Image import new [as 別名]
def test_signal_catches_create(self):
"""db_action signal should catch creation of any model entry"""
# some foreign model such as auth.user
user = User.objects.create_user("dumb", "[email protected]", "user")
self.assertEqual(self.dbaction_count + 1, DbAction.objects.count())
img = Image.new("RGBA", size=(200, 200), color=(255, 0, 0, 0))
temp_handle = StringIO.StringIO()
img.save(temp_handle, 'png')
temp_handle.seek(0)
# some local model
Profile.objects.create(user=user, birth_date=datetime.date.today(),
bio="bio", contacts="contacts",
jabber="jab", skype="sky",
photo=ContentFile(temp_handle.read()))
self.assertEqual(self.dbaction_count + 2, DbAction.objects.count())