完成图像翻转

master
charlie 4 years ago
parent 5212566fbd
commit f4c4a382bc

@ -12,4 +12,5 @@ urlpatterns = [
path('resize', views.resize),
path('rotate', views.rotate),
path('translation', views.translation),
path('flip', views.flip)
]

@ -371,5 +371,19 @@ def translation(request):
return HttpResponse('请使用POST方法')
@csrf_exempt
def flip(request):
if request.method == 'POST':
para = json.loads(request.body)
image = para['img']
img = cv2.imread(PREFIX + image)
flip_code = para.get('flip', 1)
img = cv2.flip(img, flip_code)
filename = getImageName() + DEFAULT_FORMAT
cv2.imwrite(PREFIX + filename, img)
return HttpResponse(filename)
return HttpResponse('请使用POST方法')
def r(request):
return render(request, 'upload.html')

Loading…
Cancel
Save