def image_face_detect(self, image, output=None):
"""Get the image, detect faces and write results.
:param image: (str or sppasImage) Image filename
:param output: (str) The output name for the image
:return: (list) the coordinates of all detected faces or created filenames
"""
if isinstance(image, sppasImage) is False:
image = sppasImage(filename=image)
self.__fdi.detect(image)
if self._options['portrait'] is True:
try:
self.__fdi.to_portrait(image)
except Exception as e:
self.logfile.print_message("Faces can't be scaled to portrait: {}".format(str(e)), indent=2, status=annots.error)
coords = [c.copy() for c in self.__fdi]
if output is not None:
output_file = self.fix_out_file_ext(output, out_format='IMAGE')
new_files = self.__img_writer.write(image, coords, output_file, self.get_output_pattern())
return new_files
return coords