Django, sorl-缩略图裁剪图片头像
伙计们,我想知道 sorl-thumbnail 是否有任何从下到上裁剪的选项...我有一个垃圾问题,在某些图片中 sorl-thumbnail 正在裁剪图片中人物的头部。
谢谢
guys, i would like to know if sorl-thumbnail have any option to crop from the bottom to the top... i have a litter problem, in some picture sorl-thumbnail is croping the head of the people in pictures.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我刚刚发布了 sorl-thumbnail (3.2.5) 的新版本,受 btol45 答案的启发,可以从边缘进行裁剪和智能裁剪。
引用文档:
I've just released a new version of sorl-thumbnail (3.2.5) with cropping from edge and smart cropping inspired by btol45's answer.
Quoting the docs:
我不相信这已内置到 solr-thumbnails 中,但这是我从 reddit 抄来的一个插件,它可以完成您所追求的任务。它并不完美,但它往往可以完成工作。它不会从下到上裁剪,而是使用切片的熵来确定从哪一端裁剪。它比 Reddit 版本略有改进,因为它可以处理纵向或横向图像。
I don't believe this is built into solr-thumbnails yet, but here's a plugin I cribbed from reddit that accomplishes what you're after. It's not perfect, but it tends to get the job done. It doesn't crop from bottom to top, but rather uses the entropy of the slices to determine what end to crop from. It's a slight improvement on the reddit version as it handles either portrait or landscape images.
这个问题很老了,但是,由于它在搜索 django smart Crop 时出现在 Google 中的第一个结果,所以我想添加我的小颗粒。
这个“crop=auto”功能被添加到 sorl 中,但后来又被删除了。因此,对于其他可能有此需求的人,您可以尝试:
https://github.com/francescortiz/image< /a>
它允许您通过管理员设置图像的注意力中心。
This question is old, but, since it appears as the first result in Google when searching for django smart crop, I want to add my little grain.
This "crop=auto" feature got added to sorl, but later, it got removed again. So, for others who might come with this need, you can try:
https://github.com/francescortiz/image
which allows you to set the center of attention of an image through the admin.
虽然原始答案不再有效,但在最新版本的 sorl 中,您可以指定以空格分隔的 x 和 y 裁剪值。例如,crop=“center top”,将以 X 为中心,但将顶部保留在 Y 中,这对于我的情况下的人物照片来说更好,但并不完美。
While the original answer no longer works, in recent versions of sorl, you can specify space-separated x and y crop values. For example, crop="center top", will center in X but keep the top in Y, which was better for pictures of people in my case, but not perfect.