repo_description: Hey is a decentralized and permissionless social media app built with Lens Protocol 🌿
repo_topics: blockchain crypto dapp graphql hacktoberfest lens-protocol nextjs react social-media tailwindcss turborepo typescript vitest wagmi web3
code: const getFileFromDataURL = (
    dataUrl: string,
    fileName: string,
    callback: (file: File) => void
  ) => {
    const img = new Image();
    img.crossOrigin = "Anonymous";
    img.src = dataUrl;
  
    img.onload = () => {
      const canvas = document.createElement("canvas");
      const ctx = canvas.getContext("2d");
      canvas.width = img.width;
      canvas.height = img.height;
      ctx?.drawImage(img, 0, 0, img.width, img.height);
  
      canvas.toBlob((blob) => {
        if (blob) {
          const file = new File([blob], fileName, { type: blob.type });
          callback(file);
        }
      });
    };
    img.onerror = () => {
      // Ignore errors
    };
  };
  
  export default getFileFromDataURL;
  