Example #1
0
 def testOpenImage(self):
     img = img_utils.open(self.imgPath, "yuanfang.png")
     print img.__class__
     self.assertTrue(isinstance(img, Image.Image))
     
     img1 = img_utils.open(self.imgPath, "xi-ma.jpeg")
     print img1.__class__
     self.assertTrue(isinstance(img1, Image.Image))
Example #2
0
def setPic(request, template=settings.TEMPLATE_SETTINGS):
    """切剪并设置头像"""
    
    profile = request.user.get_profile()

    if not profile.tmp_pic:
        profile.tmp_pic = profile.big_pic
        profile.save()
    
    if request.method != 'POST':
        return render_to_response(settings.TEMPLATE_SETUP_PICTURE, RequestContext(request,))
    
    img = None
    try:
        img = img_utils.open(PIC_ROOT, profile.tmp_pic)
    except IOError, Exception:
        utils.addMsg(request, messages.ERROR, u"读取文件错误!")
        return HttpResponseRedirect(reverse("profiles_setpic"))
Example #3
0
 def testCutImage(self):
     img = img_utils.open(self.imgPath, "xi-ma.jpeg") 
     self.assertTrue(img_utils.cut(img, (100, 100, 150, 150), (300, 300), self.tmpPath, 100))
Example #4
0
 def testScaleImage(self):
     img = img_utils.open(self.imgPath, "xi-ma.jpeg")
     self.assertTrue(img_utils.scale(img, (128, 128), self.tmpPath, 100))
Example #5
0
 def testThumbImage(self):
     img = img_utils.open(self.imgPath, "xi-ma.jpeg")
     self.assertTrue(img_utils._thumb(img, (100, 100)))
     self.assertTrue(img_utils._save(img, self.imgPath, 'xi-ma-thumb.jpeg'))
Example #6
0
 def testSaveImage(self):
     img = img_utils.open(self.imgPath, "xi-ma.jpeg")
     self.assertTrue(img_utils._save(img, self.imgPath, "xi-ma-test.jpeg", create_dir=False))
     
     img1 = img_utils.open(self.imgPath, "xi-ma.jpeg")
     self.assertTrue(img_utils._save(img1, "/home/junn/temp/pic/", "xi-ma-test1.jpeg", create_dir=True))