编辑图片/就地“移动” (类似于 Facebook 个人资料图片编辑)

发布于 2024-11-09 12:41:05 字数 262 浏览 4 评论 0原文

Facebook 如何对个人资料图片进行“移动”?

要了解我在说什么,请转到:http://www.facebook.com/ editprofile.php?sk=图片 -->编辑缩略图 -->请注意,您可以移动缩略图。

他们称之为“ProfilePicSquareEditor”(他们的源代码很难获得)

How does facebook do inplace "moving" about of profile pictures?

To see what I'm talking about, goto: http://www.facebook.com/editprofile.php?sk=picture --> Edit Thumbnail --> Notice that you can move the thumbnail picture about.

They're calling it "ProfilePicSquareEditor" (their source code is hard to get at)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

月隐月明月朦胧 2024-11-16 12:41:05

这并不完全是 Facebook 使用的方法,但它的效果非常好 http://odyniec.net/projects/imgareaselect/

我目前正在几个项目中使用它。

This is not exactly what Facebook uses but it does the trick very well http://odyniec.net/projects/imgareaselect/

I'm currently using it in a couple of projects.

难忘№最初的完美 2024-11-16 12:41:05

显然,有一堆 JavaScript 来控制裁剪窗口的拖动调整大小,如果您强制执行特定的宽高比(或范围),这可能会变得有点复杂(或至少乏味),但就 HTML 而言,它只是一个黑色背景 div,完整图像位于 opacity: .5 之上(这创建了变暗的背景图像),然后位于 中的同一图像的另一个副本位置:绝对 div(位于第一个 div 之外),因此它与第一个图像正确对齐。响应调整大小手柄拖动事件的处理程序不断更新 topleftwidthheight绝对定位的 div(“裁剪窗口”)的属性,以及其中“前景”图像的 topleft 属性(进入负片)以保持它与背景图像对齐。

JavaScript 还会跟踪每个角的位置,因此当用户接受更改时,这些点可以转换为像素坐标(考虑到任何缩放)并馈送到后端的任何图像处理库。

Obviously there's a bunch of javascript to control the drag resizing of the crop window, which can get a little complex (or at least tedious) if you're enforcing a certain aspect ratio (or range), but as far as the HTML is concerned, it's simply a black background div with the full image sitting on top of that at opacity: .5 (this created the darkened background image), then another copy of the same image sitting in an position: absolute div (which is outside of that first div) so it lines up correctly with the first image. A handler that responds to the drag events of the resize handles continuously updates the top, left, width and height properties of the absolutely positioned div (the 'crop window'), and also the top and left properties (into the negative) of the 'foreground' image inside it to keep it aligned with the background image.

The javascript would also keep track of the position of each corner, so when the user accepts the changes, those points can be translated into pixel coordinates (taking any scaling into consideration) and fed to whatever image processing library is on the backend.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文