onurzorluer / react-image-file-resizer

Resize Local Images with React šŸŒ„ šŸŒ…
MIT License
313 stars 41 forks source link

Exact sizing not respected #94

Open peacechen opened 2 months ago

peacechen commented 2 months ago

Describe the bug Passing in a width value to both maxWidth & minWidth, as well as a height to both maxHeight & minHeight, does not resize to the desired width & height values. It appears to prioritize minWidth/minHeight and ignore max.

@onurzorluer Would you merge a PR that fixes this?

To Reproduce Steps to reproduce the behavior:

    Resizer.imageFileResizer(
      file,
      1024, // maxWidth
      768, // maxHeight
      "PNG",
      100,
      0,
      async resizedBlob => resolve(resizedBlob as Blob),
      "blob",
      1024, // minWidth
      768, // minHeight
    );

The resulting image has the dimensions 1365 x 1024 instead of 1024 x 768. It should ignore the original aspect ratio and resize to the provided values.

Expected behavior Output image should be 1024 x 768.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Additional context NA