签名图片优化
This commit is contained in:
parent
503fa805a7
commit
850817c04e
|
@ -78,8 +78,8 @@ class AtWorkCountView(CreateAPIView):
|
||||||
serializer.is_valid(raise_exception=True)
|
serializer.is_valid(raise_exception=True)
|
||||||
vdata = serializer.validated_data
|
vdata = serializer.validated_data
|
||||||
ret = ClockRecord.objects.filter(
|
ret = ClockRecord.objects.filter(
|
||||||
create_time__year = vdata['year'],
|
update_time__year = vdata['year'],
|
||||||
create_time__month = vdata['month']
|
update_time__month = vdata['month']
|
||||||
).values(
|
).values(
|
||||||
user_id = F('create_by'),
|
user_id = F('create_by'),
|
||||||
username = F('create_by__username'),
|
username = F('create_by__username'),
|
||||||
|
|
|
@ -11,3 +11,4 @@ psutil==5.8.0
|
||||||
pillow==8.3.1
|
pillow==8.3.1
|
||||||
opencv-python==4.5.3.56
|
opencv-python==4.5.3.56
|
||||||
django-celery-results==2.2.0
|
django-celery-results==2.2.0
|
||||||
|
numpy==1.21.2
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import os
|
||||||
from rest_framework.response import Response
|
from rest_framework.response import Response
|
||||||
from rest_framework.views import APIView
|
from rest_framework.views import APIView
|
||||||
from rest_framework.parsers import MultiPartParser
|
from rest_framework.parsers import MultiPartParser
|
||||||
|
@ -57,8 +58,10 @@ class GenSignature(APIView):
|
||||||
image[i][j][3] = 0
|
image[i][j][3] = 0
|
||||||
else:
|
else:
|
||||||
image[i][j][0],image[i][j][1],image[i][j][2] = 0,0,0
|
image[i][j][0],image[i][j][1],image[i][j][2] = 0,0,0
|
||||||
cv2.imwrite(path,image)
|
ext = os.path.splitext(path)
|
||||||
return Response(request.data, status=status.HTTP_200_OK)
|
new_path = ext[0] + '.png'
|
||||||
|
cv2.imwrite(new_path,image)
|
||||||
|
return Response({'path':new_path}, status=status.HTTP_200_OK)
|
||||||
except:
|
except:
|
||||||
return Response('签名照处理失败,请重新上传',
|
return Response('签名照处理失败,请重新上传',
|
||||||
status=status.HTTP_400_BAD_REQUEST)
|
status=status.HTTP_400_BAD_REQUEST)
|
||||||
|
|
Loading…
Reference in New Issue