def anonmeyes(imagepath, picture): picture = os.path.join(imagepath, picture) image = Image.open(picture) data = list(image.getdata()) image_no_exif = Image.new(image.mode, image.size) image_no_exif.putdata(data) randomstring = str(uuid.uuid4()) filename = os.path.join(imagepath + '/cleaned', randomstring + '.png') image_no_exif.save(filename) prototxtPath = resource_path("deploy.prototxt") weightsPath = resource_path("res10_300x300_ssd_iter_140000.caffemodel") net = cv2.dnn.readNet(prototxtPath, weightsPath) # load the input image from disk, clone it, and grab dimensions image.close() image = cv2.imread(filename) orig = image.copy() (h, w) = image.shape[:2] # construct a blob from the image blob = cv2.dnn.blobFromImage(image, 1.0, (300, 300), (104.0, 177.0, 123.0)) net.setInput(blob) detections = net.forward() # loop over the detections for i in range(0, detections.shape[2]): confidence = detections[0, 0, i, 2] # filter out weak detections if confidence > 0.3: # compute the (x, y)-coordinates of the bounding box for the # object box = detections[0, 0, i, 3:7] * np.array([w, h, w, h]) (startX, startY, endX, endY) = box.astype("int") # extract the face ROI face = image[startY:endY, startX:endX] face = anonymize_face_pixelate(face, blocks=12) # store the blurred face in the output image image[startY:endY, startX:endX] = face os.remove(filename) cv2.imwrite(filename, image) loadfile = str(filename) change_image(loadfile) root.update() return filename
def redOrBlack (im): newimdata = [] redcolor = (0, 0, 0) redcolor1 = (105, 105, 105) blackcolor = (255,0,0) for color in im.getdata(): if color >= redcolor or color <= redcolor1: newimdata.append( (0,125,0) ) else: newimdata.append( color) newim = Image.new(im.mode,im.size) newim.putdata(newimdata) return newim redOrBlack(im).save("Faces/fotso.png") #img.save("Faces/foto.png")
def version_icon(request, project_id, version_integer): if int(version_integer) < 0: return None project = Project.objects.get(pk=project_id) versions = project.application.versions version = versions.filter(version_integer=version_integer)[0] img_uri = config.APPS_FOLDER + str(project.pk) + "/" + str(version.version_integer) + "/" + "icon.png" try: with open(img_uri, "rb") as f: content_length = os.path.getsize(img_uri) response = HttpResponse(f.read(), content_type="image/jpeg") response['Content-Length'] = content_length return response except IOError: red = Image.new('RGBA', (1, 1), (255, 0, 0, 0)) response = HttpResponse(mimetype="image/jpeg") red.save(response, "JPEG") return response
def __init__(self): super().__init__() uic.loadUi('ui.ui', self) self.pushButton.clicked.connect(self.create_circles) self.image = Image.new("RGBA", (700, 700), (0, 0, 0, 0)) self.draw = ImageDraw.Draw(self.image)