签名图片优化

This commit is contained in:
caoqianming 2022-01-27 13:38:07 +08:00
parent 503fa805a7
commit 850817c04e
3 changed files with 8 additions and 4 deletions

View File

@ -78,8 +78,8 @@ class AtWorkCountView(CreateAPIView):
serializer.is_valid(raise_exception=True)
vdata = serializer.validated_data
ret = ClockRecord.objects.filter(
create_time__year = vdata['year'],
create_time__month = vdata['month']
update_time__year = vdata['year'],
update_time__month = vdata['month']
).values(
user_id = F('create_by'),
username = F('create_by__username'),

View File

@ -11,3 +11,4 @@ psutil==5.8.0
pillow==8.3.1
opencv-python==4.5.3.56
django-celery-results==2.2.0
numpy==1.21.2

View File

@ -1,3 +1,4 @@
import os
from rest_framework.response import Response
from rest_framework.views import APIView
from rest_framework.parsers import MultiPartParser
@ -57,8 +58,10 @@ class GenSignature(APIView):
image[i][j][3] = 0
else:
image[i][j][0],image[i][j][1],image[i][j][2] = 0,0,0
cv2.imwrite(path,image)
return Response(request.data, status=status.HTTP_200_OK)
ext = os.path.splitext(path)
new_path = ext[0] + '.png'
cv2.imwrite(new_path,image)
return Response({'path':new_path}, status=status.HTTP_200_OK)
except:
return Response('签名照处理失败,请重新上传',
status=status.HTTP_400_BAD_REQUEST)