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.

gatsby-plugin-sharp | Support withoutEnlargement

See original GitHub issue

Summary

The Sharp resize() function has a useful option: withoutEnlargement that can be used to prevent source images from being enlarged beyond their original size, which helps prevent undesirable degradation in image quality. It would be nice if Gatsby Plugin Sharp exposed this option as a Shared Option.

Basic example

childImageSharp{
    fixed(
        width: 1000
        height: 600
        withoutEnlargement: true
    ){
        ...GatsbyImageSharpFixed
    }
}
childImageSharp{
    fluid(
        maxWidth: 1000
        maxHeight: 600
        withoutEnlargement: true
    ){
        ...GatsbyImageSharpFluid
    }
}
childImageSharp{
    resize(
        width: 1000
        height: 600
        withoutEnlargement: true
    ){
        ...GatsbyImageSharpResize
    }
}

Motivation

There are use cases where it is desirable to limit the resizing of an image to sizes that are <= its original size, in order to prevent loss in image quality. The withoutEnlargement option allows you to enforce this restriction. It would be great if Gatsby’s Sharp plugin exposed this functionality.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
ascorbiccommented, Jan 15, 2021

It’s still in beta, but should be stable next month

0reactions
marcotisicommented, Jan 15, 2021

Thank you, I’ll take a look at the new resolver

Read more comments on GitHub >

github_iconTop Results From Across the Web

gatsby-plugin-sharp
Exposes several image processing functions built on the Sharp image processing library. This is a low-level helper plugin generally used by other Gatsby...
Read more >
[gatsby-plugin-sharp] Support Default Configuration #5531
Summary At present there is no way to define default configuration for images used on a Gatsby site. The only option is to...
Read more >
gatsby-plugin-sharp | Yarn - Package Manager
Exposes several image processing functions built on the Sharp image processing library. This is a low-level helper plugin generally used by other Gatsby...
Read more >
"Gatsby-plugin-sharp wasn't setup correctly in gatsby-config.js ...
Got the same error message but from Netlify build log. Was able to resolve by updating to latest version: npm install ...
Read more >
Images in Gatsby Using gatsby-image & gatsby-plugin-sharp
If you've enjoyed this tutorial and our broader community, consider checking out our DigitalOcean products which can also help you achieve your ...
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