Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug report: Cannot load exr image in URI format (data:image/x-exr;base64, ) #20

Open
hchoi405 opened this issue Oct 20, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@hchoi405
Copy link

First of all, thank you for maintaining this repository.

While I'm making a third-party app using Jeri, I found that it cannot load the HDR image in URI format, that is in data:image/x-exr;base64,~, whereas other types of LDR images (tested jpg, png) are loaded successfully.

Here is a sample code that reproduces the problem. Run the HTML then press the Choose File button to select any images like the image images/test_image.exr or images/test_image.jpg given in this repository

<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>Example: Basic</title>
  <style>
    .stretch {
      width: 100%;
      height: 100%;
      position: absolute;
      left: 0;
      right: 0;
      top: 0;
      bottom: 0;
    }
  </style>
</head>

<body>
  <div style="width:100%; height: 80vh; position: relative;">
    <canvas id="image-layer" class="stretch"></canvas>
    <div id="mouse-layer" class="stretch"></div>
  </div>

  <input type="file" onchange="encodeImageFileAsURL(this)" />

  <script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.8.6/umd/react.development.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.8.6/umd/react-dom.development.js"></script>
  <script src="./jeri.js"></script>
  </script>
  <script>
    const ImageLayer = Jeri.ImageLayer;
    const MouseLayer = Jeri.MouseLayer;

    const cache = new Jeri.ImageCache();

    function encodeImageFileAsURL(element) {
      var file = element.files[0];
      var reader = new FileReader();
      reader.onloadend = function () {
        cache.get(reader.result)
          .then((image) => {
            const imageLayer = new ImageLayer(document.getElementById('image-layer'), image);
            const mouseLayer = new MouseLayer(document.getElementById('mouse-layer'), image);
            mouseLayer.setEnableMouseEvents(true);
            mouseLayer.onTransformationChange(function (transformation) {
              imageLayer.setTransformation(transformation);
            });
          })
          .catch((error) => console.error(error));
      }
      reader.readAsDataURL(file);
    }
  </script>
</body>

</html>
@cbreak-black cbreak-black added the enhancement New feature or request label Oct 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants