project/kiwipycon/user/utils.py
changeset 29 32b000ad43b9
parent 1 fda1c66b25f9
equal deleted inserted replaced
28:09032925ad9d 29:32b000ad43b9
    64     filename= None
    64     filename= None
    65     if photo:
    65     if photo:
    66         filename = handle_uploaded_photo(user, request.FILES['photo'])
    66         filename = handle_uploaded_photo(user, request.FILES['photo'])
    67     if filename:
    67     if filename:
    68         profile.photo = filename
    68         profile.photo = filename
    69     print photo, filename
    69     #print photo, filename
    70 
    70 
    71     profile.url = data.get("url")
    71     profile.url = data.get("url")
    72     profile.about = data.get("about")
    72     profile.about = data.get("about")
    73     profile.save()
    73     profile.save()
    74 
    74 
   109         elif pr < nr:
   109         elif pr < nr:
   110             # photo aspect is taller than destination ratio
   110             # photo aspect is taller than destination ratio
   111             th = int(round(nw / pr))
   111             th = int(round(nw / pr))
   112             image = image.resize((nw, th), Image.ANTIALIAS)
   112             image = image.resize((nw, th), Image.ANTIALIAS)
   113             t = int(round(( th - nh ) / 2.0))
   113             t = int(round(( th - nh ) / 2.0))
   114             print((0, t, nw, t + nh))
   114             #print((0, t, nw, t + nh))
   115             image = image.crop((0, t, nw, t + nh))
   115             image = image.crop((0, t, nw, t + nh))
   116         else:
   116         else:
   117             # photo aspect matches the destination ratio
   117             # photo aspect matches the destination ratio
   118             image = image.resize((nw, nh), Image.ANTIALIAS)
   118             image = image.resize((nw, nh), Image.ANTIALIAS)
   119 
   119