question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Resize if image is bigger than a specific size

See original GitHub issue

With ImageMagic you can run:

mogrify -resize '800x800>' *

Which will resize a file only if its width OR height is bigger than 800. The image’s original aspect ration will also be maintained. Is there such a “shortcut” option for sharp? Or, should I call metadata() first and then resize accordingly, depending on what I get?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:10 (9 by maintainers)

github_iconTop GitHub Comments

16reactions
papandreoucommented, Dec 22, 2017

sharp().withoutEnlargement().resize(800, 800)...

3reactions
Nik-olocommented, Oct 30, 2019

deprecated max() for { fit: sharp.fit.inside }.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to resize an image in HTML? - ImageKit.io
One of the simplest ways to resize an image in the HTML is using the height and width attributes on the img tag....
Read more >
Resize Images Proportionally While Keeping The Aspect Ratio
Our first choice is to set only one size property, either width or height , the browser will automatically calculate the size of...
Read more >
How to Resize and Make Images Larger without Losing Quality
First, you need to enter your desired image size in the 'Set new size' field by defining the width and height.
Read more >
How do I auto-resize an image to fit a 'div' container?
To resize an image proportionally, you have to set either the height or width to "100%", but not both. If you set both...
Read more >
Change the size of a picture, shape, text box, or WordArt
If you want to stretch, shrink, or just change the size of a picture (or shape), use the sizing handles or for more...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found