def crop_avatar2(): form = CropAvatarForm() if form.validate_on_submit(): x = form.x.data y = form.y.data w = form.w.data h = form.h.data filenames = avatars.crop_avatar(current_user.avatar_raw2, x, y, w, h) db.session.commit() flash('Avatar updated.', 'success') flash_errors(form) return redirect(url_for('.change_avatar2'))
def crop_avatar(): form = CropAvatarForm() if form.validate_on_submit(): x = form.x.data y = form.y.data w = form.w.data h = form.h.data filenames = avatars.crop_avatar(current_user.avatar_raw, x, y, w, h) current_user.avatar_s = filenames[0] current_user.avatar_m = filenames[1] current_user.avatar_l = filenames[2] db.session.commit() flash("Avatar updated.", "success") flash_errors(form) return redirect(url_for("user.change_avatar"))
def crop_avatar(): form = CropAvatarForm() if form.validate_on_submit(): x = form.x.data y = form.y.data h = form.h.data w = form.w.data # 裁剪头像并保存,返回三个尺寸头像的文件名 filename = avatars.crop_avatar(current_user.avatar_raw, x, y, w, h) current_user.avatar_s = filename[0] current_user.avatar_m = filename[1] current_user.avatar_l = filename[2] db.session.commit() flash('头像已更新。', 'success') flash_errors(form) return redirect(url_for('.change_avatar'))
def crop_avatar(): form = CropAvatarForm() if form.validate_on_submit(): x = form.x.data y = form.y.data w = form.w.data h = form.h.data # 裁剪头像,获取返回的三个尺寸的文件名后存库 filenames = avatars.crop_avatar(current_user.avatar_raw, x, y, w, h) current_user.avatar_s = filenames[0] current_user.avatar_m = filenames[1] current_user.avatar_l = filenames[2] db.session.commit() flash('Avatar updated', 'success') flash_errors(form) return redirect(url_for('user.change_avatar'))
def crop_avatar(): """ 裁剪头像 """ logger.info('url = ' + str(request.url)) form = CropAvatarForm() if form.validate_on_submit(): x = form.x.data y = form.y.data w = form.w.data h = form.h.data # 头像裁剪 filenames = avatars.crop_avatar(current_user.avatar_raw, x, y, w, h) # 更新头像 current_user.avatar_s = filenames[0] current_user.avatar_m = filenames[1] current_user.avatar_l = filenames[2] db.session.commit() flash('头像更新成功', 'success') flash_errors(form) return redirect(url_for('.change_avatar'))