使用 Javascript 双三次调整图像大小
有没有办法使用 JavaScript 调整实际图像的大小?我不是在谈论修改 DOM 来让浏览器调整图像大小。我实际上想调整图像像素数据的大小,然后显示它。
基本上我的问题是:Firefox 在缩小具有精细功能的图像方面完全失败,因为它只有最近邻和二元线性。所有其他浏览器(甚至 IE)都支持 Bicubic。 讨论会在不久的将来将其纳入其中,但该讨论一直在进行持续了一年多。
我不介意下载完整尺寸的图像,因为无论如何我都希望下载它们。当用户将鼠标悬停在图像的小版本上时,大版本立即出现在页面的其他位置。如果我在服务器端调整大小,我必须下载图像的两个副本,这会导致更多的流量。如果没有其他解决方法,那么这就是我必须做的......我只是不想这样做。
Is there a way to resize the actual image using JavaScript? I'm not talking about modifying the DOM to get the browser to resize the image. I actually want to resize the image's pixel data and then display that.
Basically my problem is: Firefox completely fails at downsizing images with delicate features because it only has Nearest Neighbor and Binlinear. Every other browser -- even IE -- has Bicubic support. There's talk of this being included in the near future but that talk has been going on for over a year.
I don't mind downloading the full sized images because I want them downloaded anyway. When the user hovers over the small version of an image, the large version immediately appears elsewhere on the page. If I did server-side resizing I'd have to download BOTH copies of the images which would result in even more traffic. If there's no other workaround then this is what I'm going to have to do... I just don't want to.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是可能的。您在同一域上获取图像,写入画布,然后从那里操作像素数据(很复杂,但我确信可能),然后使用它或输出为 png/gif/jpg...但是...我认为您不会发现它比 CSS 更好地保留精致功能。
It is possible. You get a image on the same domain, write to canvas, then manipulate pixel data from there (complicated, but possible I'm sure), and then either use that or output as png/gif/jpg... BUT... I don't think you will find it will better way to preserve delicate features that CSS.