h2non / imaginary

Fast, simple, scalable, Docker-ready HTTP microservice for high-level image processing
https://fly.io/docs/app-guides/run-a-global-image-service/
MIT License
5.54k stars 456 forks source link

Detect face to crop and create thumbnail #34

Closed ciceroverneck closed 7 years ago

ciceroverneck commented 8 years ago

Link thumbor. Implement a Detection Algorithms (https://github.com/thumbor/thumbor/wiki/Detection-algorithms)

h2non commented 8 years ago

Thank you! I have also in mind introduce support for smart crop, mostly following this implementation.

At this time, you can perform the smart crop calculus using another solution, and then extract the image area using imaginary.

Dynom commented 8 years ago

I believe the technical term to be Seam Carving or Liquid Rescaling. Just mentioning it here in case people search the issues for it.

I think it would be a great feature to have! But I'm curious, what should happen when no "interesting" center is determined?

Dynom commented 8 years ago

There is a Go version of smartcrop that seems fairly trivial to add to Imaginary https://github.com/muesli/smartcrop

What is your roadmap on the "smart crop" endeavor @h2non ?

h2non commented 8 years ago

The unique bad part I see here is that it depends on OpenCV. I'm not too much open in adding another C dependency which mostly provides the same as libvips.

Some intermediate solutions could be:

Dynom commented 8 years ago

So either option requires quite a bit of non-trivial work. What is the strongest argument against linking OpenCV?

Dynom commented 7 years ago

@Artyom https://github.com/artyom/smartcrop created a fork without OpenCV dependency!

Dynom commented 7 years ago

As of libvips version 8.5.0, there is a "smart crop" feature available. It's based on Sharp's smartcrop, which I think is the same as linked earlier here in the Issue.

See also:

Dynom commented 7 years ago

I've made a PR to implement bimg's smartcrop API. It's obviously not face-detection, but perhaps it's enough for your use-case @cicerocomp ?

h2non commented 7 years ago

From imaginary v1.0.8+, there is first-class support for smart cropping relying on the built-in cropping algorithm in libvips. There is no plans to support face detection in imaginary.

For more details, see the documentation: https://github.com/h2non/imaginary#get--post-smartcrop