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

Failed to load resource: the server responded with a status of 404 () #80

Open
matharotheelf opened this issue May 9, 2020 · 0 comments

Comments

@matharotheelf
Copy link

matharotheelf commented May 9, 2020

I am trying to 'square' a file using WASM-ImageMagick however I am facing an error I can't figure out. I seems that I can't load some files and my requests to the api are causing 404s.

Here is the Javascript in the 'index.html' I am running:

  <script type='module'>

    //import the library to talk to imagemagick
    import * as Magick from 'https://knicknic.github.io/wasm-imagemagick/magickApi.js';

    // various html elements
    let rotatedImage = document.getElementById('rotatedImage');

    // Fetch the image to rotate, and call image magick
    let DoMagickCall = async function () {
      let fetchedSourceImage = await fetch("artwork.jpg");
      let arrayBuffer = await fetchedSourceImage.arrayBuffer();
      let sourceBytes = new Uint8Array(arrayBuffer);

      // calling image magick with one source image, and command to rotate & resize image
      const files = [{ 'name': 'srcFile.jpg', 'content': sourceBytes }];
      const command = [
        "convert", 
        "srcFile.jpg", 
        "-bordercolor", 
        "transparent", 
        "-border", 
        "1", 
        "-set", 
        'option:distort:viewport "%[fx:max(w,h)]x%[fx:max(w,h)]-%[fx:max((h-w)/2,0)]-%[fx:max((w-h)/2,0)]"',
        "-virtual-pixel",
        "edge",
        "-distort",
        "SRT",
        "0",
        "the_square.jpg"];
      let processedFiles = await Magick.Call(files, command);

      // response can be multiple files (example split)
      // here we know we just have one
      let firstOutputImage = processedFiles[0]
      rotatedImage.src = URL.createObjectURL(firstOutputImage['blob'])
      console.log("created image " + firstOutputImage['name'])
    };
    DoMagickCall();
  </script>

I get the following errors:

Screen Shot 2020-05-09 at 18 20 23

I would appreciate any help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant