-
Notifications
You must be signed in to change notification settings - Fork 538
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
How could i crop an image to circle? #214
Comments
Thanks for contacting us @lanlin For example, this is a very simple example which only supports square images making circle. if (key === 'circle') {
let { width, height } = metadata;
if (edits.resize) {
width = edits.resize.width ? edits.resize.width : width;
height = edits.resize.height ? edits.resize.height : height;
}
const rect = Buffer.from(`<svg><rect x="0" y="0" width="${width}" height="${height}" rx="100" ry="100"/></svg>`);
const params = [{ input: rect, blend: 'dest-in' }];
image.composite(params);
} And you can create encoded URL with: const j = JSON.stringify({
bucket: 'your-bucket',
key: 'your-image',
edits: {
circle: ''
}
});
const encoded = Buffer.from(j).toString('base64'); |
@beomseoklee thanks very much. Would you please add this feature in the next release? |
Where this code should be implemented ? |
@haoujey You can implement that part in |
thanks ! :) |
We've added support for circular cropping in v5.2.0. |
I want to crop an image to the circle so that I can use it as an avatar, how to do this?
The text was updated successfully, but these errors were encountered: