Crop image using aspect ratio instead of dimensions
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 32.7k
- Forks
- 1.4k
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 5
Description
It would be great if there was a builtin function that allowed us to crop images based on aspect ratio instead of dimensions. The input to such a function could be the aspect ratio and (probably) a gravity. Basically, the function would calculate the largest possible dimensions based on the aspect ratio, the gravity would influence the starting point.
There was a similar feature request. However, it was solved for 1:1, but I need to crop a 9:16 image to 16:9.
Here's a sample of how the function would look like:
```
aspect(16 / 9, "centre")
```
I could create a PR implementing this function. Someone would have to guide me though. :sweat_smile:
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names no implementation file or test. Start by locating sharp's existing crop/resize entry point and the prior 1:1 aspect-ratio feature mentioned here; confirm how a 16:9 crop and gravity should behave, then add coverage showing the requested aspect-ratio result.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- computer-graphics
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100