gatsbyjs / gatsby

The best React-based framework with performance, scalability and security built in.
https://www.gatsbyjs.com
MIT License
55.13k stars 10.33k forks source link

fix(gatsby-plugin-sharp): read aspectRatio from the largest image possible #39008

Open gera2ld opened 3 weeks ago

gera2ld commented 3 weeks ago

Description

Currently gatsby-plugin-sharp returns the aspectRatio of images[0], which is the smallest image and likely has the most inaccurate aspectRatio. The fix changes images[0] to images[images.length - 1] to use the largest image.

Documentation

No documentation is needed since it's an internal fix.

Tests

I've added a unit test to process an image of 1000x746. The accurate aspectRatio should be 0.746 while the smallest image has a ratio of 0.7466....

Related Issues

Fixes #24212