feat: add support for resizing images #96
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
👋🏻 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:
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
methodresize
which have few default configs. So for eg: if width and height are defined it crops the image as the defaultfit
value iscover
. Read more here: https://sharp.pixelplumbing.com/api-resize#resizeWhat does this PR introduce?
In a few bullet points, please describe the changes this Pull Request makes. E.g.:
Related issues
Closes #20 #60
Testing steps
Test 1
All the files was resized.
Test 2
Only icon image was resized.
cc @benschwarz @mikedijkstra