muesli / smartcrop

smartcrop finds good image crops for arbitrary crop sizes
MIT License
1.82k stars 114 forks source link

Decouple the resizer #31

Closed bep closed 6 years ago

bep commented 6 years ago

This commit adds a new Resizer interface with the resizer from nfnt as the default in its own package.

This allows people to use the smartcrop library with their own resize implemention.

My motivation for this is to use this in Hugo. We use github.com/disintegration/imaging to do image processing -- github.com/nfnt/resize is probably equally good, but imaging had a richer API for the Hugo use cases.

I have tested this library and I'm really impressed by the results (and the speed):

http://hugotest.bep.is/resourcemeta/smartcrop/

The relevant Hugo PR is here:

https://github.com/gohugoio/hugo/pull/4376

I know this is breaking some API, but I think people are happy to adjust as long as it is for a greater good. And this is < 1.0 software, and it is super-easy to upgrade.

Again, tanks for this great piece of software.

coveralls commented 6 years ago

Coverage Status

Coverage increased (+0.2%) to 83.934% when pulling f0c4f3dbe7df63f8b8c8a6b3657ead8ee57102cf on bep:resizer-decouple into 9032446b30f6284f8718490b6bcff8a1d51173cf on muesli:master.

bep commented 6 years ago

The Travis failures seem to be unrelated.

muesli commented 6 years ago

@bep The Travis issue is indeed unrelated to your changes. I'm in touch with their support, as it affects pretty much all of my projects currently.

muesli commented 6 years ago

Awesome, looks good to me. Thanks for the nice contribution! Do you plan to commit your alternative resizer as well, or do you want to keep it in your own repo / package? (I can see perfectly valid reasons doing it either way)

Looking forward to seeing this supported in Hugo!

bep commented 6 years ago

Do you plan to commit your alternative resizer as well, or do you want to keep it in your own repo / package?

That wasn't the plan. Not sure how useful that is ...

bep commented 6 years ago

That wasn't the plan. Not sure how useful that is ...

That said, if you want me to, I could do so, no problem.

muesli commented 6 years ago

@bep No, I think it's fine. It might still be useful to others, so maybe we should at least link to its source. I assume it's in a public repo anyway?

bep commented 6 years ago

I assume it's in a public repo anyway?

Yes. https://github.com/gohugoio/hugo -- but it's still, for natural reasons, in pull request mode in that repo, too.

muesli commented 6 years ago

Yeah, we should point to that source once it's all merged on both sides. Speaking about it: I'm gonna click a little merge button here now. Thanks for the contribution again!