有没有办法在将图像保存到数据库之前对其进行编辑?
我们的图像由用户在 Web 应用程序 (React) 上上传,并通过我们的 API (Loopback) 保存在数据库中。
这些图像将在我们的 Qt 应用程序中使用,并且它们应该具有圆角。我们有一些处理限制,因此我们无法在 Qt 上剪辑或屏蔽图像。
我们现在有一些不成比例的图像,其中的干角破坏了布局,我需要一种方法将它们裁剪为正确的比例,并在所有 4 个角上都有边框半径。对于我们的下一个应用程序,我们应该有两个圆角和两个方形,但如果这是不可能的,我可以尝试更改它。
到目前为止我研究过的内容:
- 裁剪库(很多,但大多数都有矩形或圆形作为形状选项,并且没有明确的方法来自定义形状)。
- 将预先保存的蒙版添加到图像的 Alpha 通道的方法(无法真正找出可行的方法)。
- HTML 标签画布(仍在尝试这种方法)。
我愿意尝试几乎任何事情,只要它不涉及对 Qt 应用程序的重大更改。
Our images are being uploaded by the users on the web application (React) and being saved on the database by our API (Loopback).
The images will be used in our Qt application and they should have round corners. We have some processing limitations so we can't clip or mask the images on Qt.
We have some out of proportion images with dry corners breaking the layout right now and I need a way to crop them to the correct proportions with a border radius on all 4 corners. For our next application we should have two rounded corners and two squared ones but if this isn't possible I can try and change it.
What I have researched so far:
- Cropping libraries (lots of them, but most had rectangle or circle as options for shapes and no clear way to customize the shape).
- Ways to add a pre-saved mask to the alpha channel of the image (couldn't really figure out a way that would work).
- The HTML tag canvas (still trying this approach).
I'm willing to try almost anything as long as it doesn't involve major changes to the Qt application.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我会采用画布方法,因为您将拥有完整的自定义功能,这很有用,因为您提到稍后将更改需求。
ctx.clip()
。ctx.globalCompositeOperation = 'source-in'
I would go with the canvas approach, since you would have full customization which is useful since you mention you'll be changing the requirements later.
ctx.clip()
after drawing a custom path.ctx.globalCompositeOperation = 'source-in'
after drawing a mask imagecanvas.toDataURL()