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

Any way to crop the image into a circle, instead of a square? #74

Closed
Bengejd opened this issue Apr 16, 2018 · 4 comments
Closed

Any way to crop the image into a circle, instead of a square? #74

Bengejd opened this issue Apr 16, 2018 · 4 comments

Comments

@Bengejd
Copy link

Bengejd commented Apr 16, 2018

I am looking to crop an image into a circle, hopefully using this library, or a combination of this (to detect a person's face), and then cropping that image into a circle (limitation of another library that doesn't allow css intervention on an image).

@jwagner
Copy link
Owner

jwagner commented Apr 16, 2018

Hi Jordan,

If you just want to crop to faces I'd just use a face detection library and then crop out the circle.

If you need more smartcrop could definitely be adapted to look for round crops by changing the window.
However I don't think it is a common enough use case to justify inclusion in the library. If you really want to do this I'd suggest doing a PR against smartcrop that allows injecting a custom importance function as an option and then implementing such a function that results in a round window.

Cheers,
Jonas

@Bengejd
Copy link
Author

Bengejd commented Apr 17, 2018

I'm not looking to crop to just faces, I'm trying to use the cropping mechanism that this library provides to center an image into a crop-zone, but instead of cropping it as a square, it would crop that image into a circle.

Your examples are shown like this:

Before smartcrop.js
screen shot 2018-04-16 at 8 12 37 pm

After smartcrop.js - original example
screen shot 2018-04-16 at 8 12 42 pm

What I'm trying to achieve:
title783581518

Does that make sense, or is it the same answer unfortunately?

@jwagner
Copy link
Owner

jwagner commented Apr 17, 2018

Hi Jordan,

For optimal results the second answer applies. You could also just look for a square crop (diameter x diameter) using the existing library and then apply your circle effect, that will likely yield acceptable results too.

Cheers,
Jonas

@jwagner
Copy link
Owner

jwagner commented May 26, 2018

Closed for lack of a reply.

@jwagner jwagner closed this as completed May 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants