예제 #1
0
def mugshot(user_id):
  size = int(request.args.get('s', 0))
  if size > 500:
    raise Exception("Error, size = %d" % size)
  user = User.query.get(user_id)

  data = user.photo
  if size:
    data = crop_and_resize(data, size)

  response = make_response(data)
  response.headers['content-type'] = 'image/jpeg'
  return response
예제 #2
0
파일: social.py 프로젝트: sfermigier/yaka
def mugshot(users_or_groups, uid):
  size = int(request.args.get('s', 0))
  if size > 500:
    raise Exception("Error, size = %d" % size)

  if users_or_groups == "users":
    subject = User.query.get(uid)
    photo = subject.photo
    if not photo:
      photo = get_default_picture("user")
  else:
    subject = Group.query.get(uid)
    photo = subject.photo
    if not photo:
      photo = get_default_picture("group")

  if size:
    photo = crop_and_resize(photo, size)

  response = make_response(photo)
  response.headers['content-type'] = 'image/jpeg'
  return response