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

Inaccuracy in README.md: null Method Description in argorithm Should Reflect Fastest but Lowest Quality #19

Open
hsa00000 opened this issue May 19, 2024 · 0 comments

Comments

@hsa00000
Copy link

Inaccuracy in README.md: null Method Description in argorithm Should Reflect Fastest but Lowest Quality

Description:
The README.md file contains an inaccurate description of the null method in the argorithm property. It states that the null method provides the "best quality and fastest" resizing. However, based on the source code, the null method appears to be the fastest but with the lowest quality because it does not use any advanced algorithm.

Package Version:
2024.1.0

Problem:
The current description of the null method in the argorithm section of the README.md is misleading. It should indicate that the null method is the fastest but produces the lowest quality output.

Current README.md Snippet:

null: Just resize with drawImage(). The best quality and fastest.

Proposed Fix:
Update the description to accurately reflect the behavior of the null method.

Corrected README.md Snippet:

null: Just resize with drawImage(). The fastest but lowest quality.

Supporting Evidence:
Based on the source code of the scaleCanvasWithAlgorithm function, the null method uses scaled.getContext("2d")?.drawImage(canvas, 0, 0, scaled.width, scaled.height), which is a fast operation but does not employ any advanced algorithm for quality.

Source Code Snippet:

async function scaleCanvasWithAlgorithm(canvas, config) {
  const scale = config.outputWidth / canvas.width;
  const scaled = new OffscreenCanvas(Math.floor(config.outputWidth), getTargetHeight(canvas.height, scale, config));
  switch (config.argorithm) {
    case "hermite": {
      prepareHermit();
      await hermite.resampleAuto(canvas, scaled, config);
      break;
    }
    case "hermite_single": {
      const { srcImgData, destImgData } = getImageData(canvas, scaled);
      prepareHermit();
      hermite.resampleSingle(srcImgData, destImgData, config);
      scaled?.getContext("2d")?.putImageData(destImgData, 0, 0);
      break;
    }
    case "bilinear": {
      const { srcImgData, destImgData } = getImageData(canvas, scaled);
      bilinear(srcImgData, destImgData, scale);
      scaled?.getContext("2d")?.putImageData(destImgData, 0, 0);
      break;
    }
    default: {
      scaled.getContext("2d")?.drawImage(canvas, 0, 0, scaled.width, scaled.height);
      break;
    }
  }
  return scaled;
}

Steps to Reproduce:

  1. Check the README.md file for the description of the null method in the argorithm section.
  2. Compare the description with the source code implementation.

Suggested Labels:

  • documentation
  • bug
  • good first issue
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