使用哪个插件来调整图像大小,就像这样
Which plugin to use for image resizing like this?
>我有以下两个链接
原图:
http://img.readitlater.com/i/static01.nyt.com/images/2014/11/16/realestate/16BOERUMSUB/16BOERUMSUB-master495.jpg
调整大小的图像:
http://img.readitlater.com/i/static01.nyt.com/images/2014/11/16/realestate/16BOERUMSUB/16BOERUMSUB-master495/RS/w280-nc.jpg
我与Wappalyzer进行了检查,但没有发现任何技术。
我想做类似的事情。有没有插件?
PS:我知道市场上有很多插件,但我希望它与此类似。
这也是网站的原始链接:
http://static01.nyt.com/images/2014/11/16/realestate/16BOERUMSUB/16BOERUMSUB-master495.jpg
他们添加了一些处理程序。
此函数将调整具有指定尺寸集的任何图像的大小,同时保留纵横比。请确保仅在加载每个图像后调用该函数。
function resize_images(maxht, maxwt, minht, minwt) {
var imgs = document.getElementsByTagName('img');
var resize_image = function(img, newht, newwt) {
img.height = newht;
img.width = newwt;
};
for (var i = 0; i < imgs.length; i++) {
var img = imgs[i];
if (img.height > maxht || img.width > maxwt) {
// Use Ratios to constraint proportions.
var old_ratio = img.height / img.width;
var min_ratio = minht / minwt;
// If it can scale perfectly.
if (old_ratio === min_ratio) {
resize_image(img, minht, minwt);
}
else {
var newdim = [img.height, img.width];
newdim[0] = minht; // Sort out the height first
// ratio = ht / wt => wt = ht / ratio.
newdim[1] = newdim[0] / old_ratio;
// Do we still have to sort out the width?
if (newdim[1] > maxwt) {
newdim[1] = minwt;
newdim[0] = newdim[1] * old_ratio;
}
resize_image(img, newdim[0], newdim[1]);
}
}
}
}
相关文章:
- 如何像模糊图像一样模糊iframe
- 如何将一个模态放在一边-显示其他模态(像..这样的向导)
- 无法使用“;测试”;作为javascript中的值,但可以使用像1这样的数字
- 用Javascript正则表达式检查像x.0.0这样的字符串
- 在保存到本地存储之前,如何修改我得到的 json 响应以使其看起来像这样
- 如何使用javascript和php检查符号,像这样
- 是否可以像这样在卸载之前写入
- 为什么 js 在像 '{}[0]' 这样的语句中忽略 '{}'
- 正确的选择器字符串是什么,可以在像这样结构的 HTML 中获取我想要的特定元素
- TGALoader 正在加载垂直轴上镜像的图像
- 如何像这样显示时间,例如:1秒前,1分钟前,1小时前,1个月前
- 如何使用getElementsByClassName检查输入中的值,像这样
- 如何在示例中构建像这样的简单图像旋转效果
- 使用哪个插件来调整图像大小,就像这样
- 为什么像这样向 JavaScript 引用类型添加方法不起作用
- add(1)(2)(3).total === 6 - 有没有人见过像这样使用的自返回函数
- 仅数字的 ng 模式将接受像 “-” 这样的字符,例如 Angular.js
- 如何更改'还有一个像这样的人'当I'我已经把它添加到我的网站上了
- 如何计算两个元素之间的距离,像这样
- 为什么我不能像这样查找关联的数组