                  with open(filename, "wb") as out_file:
                      out_file.write(image)
              else:
                  cv2.imwrite(filename, image)
              logger.trace("Saved image: '%s'", filename)
          except Exception as err:  # pylint: disable=broad-except
              logger.error("Failed to save image '%s'. Original Error: %s", filename, err)
  
      def save(self, filename, image):
          """ Save the given image in the background thread
 
</s> remove     def save(self, filename, image):
 </s> add     def save(self, filename: str, image: bytes, sub_folder: Optional[str] = None) -> None: </s> remove         filename = os.path.join(self.location, os.path.basename(filename))
 </s> add         location = os.path.join(self.location, sub_folder) if sub_folder else self._location
        if sub_folder and not os.path.exists(location):
            os.makedirs(location)

        filename = os.path.join(location, os.path.basename(filename)) </s> remove         image: numpy.ndarray
            The image to be saved
 </s> add         image: bytes
            The encoded image to be saved
        subfolder: str or ``None``
            If the file should be saved in a subfolder in the output location, the subfolder should
            be provided here. ``None`` for no subfolder. </s> remove         logger.trace("Putting to save queue: '%s'", filename)
        self._queue.put((filename, image))
 </s> add         logger.trace("Putting to save queue: '%s'", filename)  # type:ignore
        self._queue.put((filename, image, sub_folder)) </s> remove     def _save(self, filename, image):
 </s> add     def _save(self, filename: str, image: bytes, sub_folder: Optional[str]) -> None:
            logger.trace("Saved image: '%s'", filename)  # type:ignore
                  with open(filename, "wb") as out_file:
                      out_file.write(image)
              else:
                  cv2.imwrite(filename, image)
            logger.trace("Saved image: '%s'", filename)  # type:ignore
          except Exception as err:  # pylint: disable=broad-except
              logger.error("Failed to save image '%s'. Original Error: %s", filename, err)
  
      def save(self, filename, image):
          """ Save the given image in the background thread
keep keep keep keep replace keep keep keep keep keep
 Extract filter: Allow saving of filtered images 
lib/image.py