alexcorvi / heic2any

Converting HEIF/HEIF image formats to PNG/GIF/JPEG in the browser
https://alexcorvi.github.io/heic2any/
MIT License
585 stars 74 forks source link

converted image url comes back undefined #51

Closed MarianaKWork closed 11 months ago

MarianaKWork commented 11 months ago

Hi!

Thanks for creating this library, I've been tearing my hair out wondering how to display heic images, but I am having some issues using the library locally.

Here is a repo that you can run locally and check what the issue is, and this is the code where I try to convert the image:

  useEffect(() => {
    const heic2any = require('heic2any');
    if (typeof window !== 'undefined') {
      fetch('https://alexcorvi.github.io/heic2any/demo/14.heic')
        .then((res) => res.blob())
        .then((blob) =>
          heic2any({
            blob,
          })
        )
        .then((conversionResult) => {
          setImg(URL.createObjectURL(conversionResult));
        })
        .catch((e) => {
          console.log(e);
        });
    }
  }, []);

Essentially, when I try use URL.createObjectURL, the url that is created for the image returns a 404 page not found when I try to open it.

Would appreciate any help with this!

MarianaKWork commented 11 months ago

Ignore this - I'm an idiot, I didn't realise the 'link' would no longer work once I navigate away (i.e. open it in a new tab), I thought it was related to my server and not the specific page I was on...