0
作物圖像錯誤地裁剪圖片
x = int(request.POST.get('x'))
y = int(request.POST.get('y'))
h = int(request.POST.get('h'))
w = int(request.POST.get('w'))
user = RegModel.objects.get(id=request.user.id)
user.cropping.delete(save=True)
picture_copy = ContentFile(user.image.read())
new_picture_name = user.image.name.split("/")[-1]
user.cropping.save(new_picture_name, picture_copy)
image = Image.open(user.cropping)
cropped_image = image.crop((x, y, w + x, h + y))
resized_image = cropped_image.resize((200, 200), Image.ANTIALIAS)
resized_image.save(user.cropping.path)
了代碼在用於crope圖像X,Y,寬度,高度,是我的模板jQuery的設定參數和我將其發送到服務器。 jquery爲我展示瞭如何看起來被歪曲的圖像,但是在服務器後端上的圖像被錯誤地顯示後。我的失敗在哪裏?
你是什麼意思,這是不正確的? – user2896976
黑色字段出現並沒有正確切出 –
你能上傳圖片給我們看 – user2896976