jwagner / smartcrop.js

Content aware image cropping

Home Page:http://29a.ch/2014/04/03/smartcrop-content-aware-image-cropping

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

Bengejd opened this issue · comments

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).

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

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?

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

Closed for lack of a reply.