code: async def crunch(image_data, format, silent=False):
      
      if (((format is CoverImageFormat.PNG) and (not HAS_OPTIPNG)) or
              ((format is CoverImageFormat.JPEG) and (not HAS_JPEGOPTIM))):
        return image_data
      with mkstemp_ctx.mkstemp(suffix=".%s" % (format.name.lower())) as tmp_out_filepath:
        if not silent:
          logging.getLogger("Cover").info("Crunching %s image..." % (format.name.upper()))
        with open(tmp_out_filepath, "wb") as tmp_out_file:
          tmp_out_file.write(image_data)
        size_before = len(image_data)
        if format is CoverImageFormat.PNG:
          cmd = ["optipng", "-quiet", "-o1"]
        elif format is CoverImageFormat.JPEG:
          cmd = ["jpegoptim", "-q", "--strip-all"]
        cmd.append(tmp_out_filepath)
        p = await asyncio.create_subprocess_exec(*cmd,
                                                 stdin=asyncio.subprocess.DEVNULL,
                                                 stdout=asyncio.subprocess.DEVNULL,
                                                 stderr=asyncio.subprocess.DEVNULL)
        await p.wait()
        if p.returncode != 0:
          if not silent:
            logging.getLogger("Cover").warning("Crunching image failed")
          return image_data
        with open(tmp_out_filepath, "rb") as tmp_out_file:
          crunched_image_data = tmp_out_file.read()
        size_after = len(crunched_image_data)
        pct_saved = 100 * (size_before - size_after) / size_before
        if not silent:
          logging.getLogger("Cover").debug("Crunching image saved %.2f%% filesize" % (pct_saved))
      return crunched_image_data
docs: Crunch image data, and return the processed data, or orignal data if operation failed.