Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for resizing images #96

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jyash97
Copy link

@jyash97 jyash97 commented May 2, 2021

👋🏻 Hi there!

Adds a new field size which accepts glob patterns and defines custom width and height for the same. This can be used to target specific image or multiple images residing under a directory.

Now in config if someone adds below config:

size: {
      "*/**/__tests__/test-images": { width: 200, height: 100 },
      "*/**/__tests__/test-images/icon.png": { width: 200, }
    }

All the files matching the glob would be resized. This can be used to target specific files, same extension files and files under a specific directory. Both width and height can be passed or either of the things can be passed. If empty object is passed it wont resize the file.

Note This is done using sharp method resize which have few default configs. So for eg: if width and height are defined it crops the image as the default fit value is cover. Read more here: https://sharp.pixelplumbing.com/api-resize#resize


What does this PR introduce?

In a few bullet points, please describe the changes this Pull Request makes. E.g.:

  • adds resizing support
  • TODO readme update

Related issues

Closes #20 #60

Testing steps

Test 1

 size: {
      "*/**/__tests__/test-images": { width: 200, height: 100 },
}

All the files was resized.

Test 2

size: {
      "*/**/__tests__/test-images/icon.png": { width: 200 },
}

Only icon image was resized.

cc @benschwarz @mikedijkstra

Adds a new field `size` which accepts glob patterns and defines custom width and height for the same. This can be used to target specific image or multiple images residing under a directory.
@CLAassistant
Copy link

CLAassistant commented May 2, 2021

CLA assistant check
All committers have signed the CLA.

@AndreasMadsen
Copy link

@benschwarz any chance of getting this merged?

@Stanzilla
Copy link

This would be really nice to have

@risograph
Copy link

please merge, this is great.

@mschfh
Copy link

mschfh commented Jan 22, 2024

@benschwarz Could this please be reviewed/merged?

@K-J-Q
Copy link

K-J-Q commented Feb 15, 2024

@benschwarz This would be useful to me as well! looking forward to the merge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Resizing Images
7 participants