使用哪个插件来调整图像大小,就像这样

Which plugin to use for image resizing like this?

本文关键字:像这样 图像 调整 插件      更新时间:2023-09-26

>我有以下两个链接

原图:

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]);
      }
    }
  }
}