function printAsJPG() {
  // Get the element to print

  const oldTextAreaMusician = $("#musician").replaceWith(
    "<div id='musician' class='bubble thought musician'>" +
      $("textarea").val().replace(/\n/g, "<br>") +
      "</div>",
  );
  const oldTextAreaWoman = $("#woman").replaceWith(
    "<div id='woman' class='bubble thought woman'>" +
      $("textarea").val().replace(/\n/g, "<br>") +
      "</div>",
  );
  const oldTextAreaMan = $("#man").replaceWith(
    "<div id='man' class='bubble thought man'>" +
      $("textarea").val().replace(/\n/g, "<br>") +
      "</div>",
  );

  const elementToCapture = document.querySelector(".image_wrapper");
  // Use html2canvas to capture the element
  html2canvas(elementToCapture).then(function (canvas) {
    const imgData = canvas.toDataURL("image/jpeg", 1.0);

    $("#musician").replaceWith(oldTextAreaMusician);
    $("#woman").replaceWith(oldTextAreaWoman);
    $("#man").replaceWith(oldTextAreaMan);

    // Create a temporary link element to trigger the download
    const link = document.createElement("a");

    // Set the href attribute to the image data (JPG file)
    link.href = imgData;

    // Set the download attribute with the desired file name
    link.download = "captured_image.jpg";

    // Programmatically click the link to trigger the download
    link.click();
  });
}
