blueimp / JavaScript-Load-Image

Load images provided as File or Blob objects or via URL. Retrieve an optionally scaled, cropped or rotated HTML img or canvas element. Use methods to parse image metadata to extract IPTC and Exif tags as well as embedded thumbnail images, to overwrite the Exif Orientation value and to restore the complete image header after resizing.
https://blueimp.github.io/JavaScript-Load-Image/
MIT License
4.46k stars 923 forks source link

Prevent scale up #139

Closed thomasdao closed 2 years ago

thomasdao commented 2 years ago

Hi,

Thank you for this fantastic library! I want to scale down the image with the cover: true option, but I do not want the image to scale up. Is there an option in the library that only scales down and not up? I search through almost all issues on Github but can not yet find the answers.

Thanks so much!

thomasdao commented 2 years ago

One possible solution I can think of is to load the image first to read the width and height and then calculate the maxWidth/maxHeight myself, but just want to check if there's faster way to do it in the library :)

blueimp commented 2 years ago

Hi @thomasdao! Yeah, unfortunately there's no specific option for that, but as you said, you can load the image first and then use the scale API with options based on the image dimensions.

thomasdao commented 2 years ago

Thanks @blueimp, I implemented that and it works fine :)