-1

Is it possible to crop an image with Gatsby to turn it into 16x9 and start from the center out? My original response it is that it is not but I want to double check before venturing to other options.

I couldn't find information about this process in the documentation either. Anyone knows if this is achievable?

Helmut Granda
  • 4,565
  • 7
  • 35
  • 51

1 Answers1

0

You can use Gatsby image with Ratio to do that!

  <StaticImage
    style={{
      gridArea: "1/1",
      // You can set a maximum height for the image, if you wish.
      // maxHeight: 600,
    }}
    layout="fullWidth"
    // You can optionally force an aspect ratio for the generated image
    aspectRatio={3 / 1}
    // This is a presentational image, so the alt should be an empty string
    alt=""
    // Assisi, Perúgia, Itália by Bernardo Ferrari, via Unsplash
    src={
      "https://images.unsplash.com/photo-1604975999044-188783d54fb3?w=2589"
    }
    formats={["auto", "webp", "avif"]}
  />

More info here: https://www.gatsbyjs.com/docs/how-to/images-and-media/using-gatsby-plugin-image/#aspect-ratio

E P
  • 389
  • 4
  • 16