【问题标题】:Know resulting image size before performing a resize in Imageresizer在 Imageresizer 中执行调整大小之前了解生成的图像大小
【发布时间】:2014-09-09 18:51:50
【问题描述】:

imageresizer 实际执行重新调整大小之前,我需要知道图像的目标大小。而且我不想打开图像文件。

我有原始图像大小和 imageresizer 参数。

我想这样写一个img标签:

<img src="/files/rb45_45667.jpg?height=150&quality=90" width="XXX" height="YYY">

我试过ImageState

var imagestate = new ImageState(new ResizeSettings("height=150;quality=90"), new Size(1000,500), true);
imagestate.destSize = PolygonMath.RoundPoints(imagestate.layout.GetBoundingBox().Size);

但这不起作用,因为我认为我应该执行所有 ImageBuilder 布局保护方法:

protected override RequestedAction Layout(ImageState s) {
    if (base.Layout(s) == RequestedAction.Cancel) return RequestedAction.Cancel;
    FlipExistingPoints(s); //Not implemented
    LayoutImage(s);
    PostLayoutImage(s);
    LayoutPadding(s);
    PostLayoutPadding(s);
    LayoutBorder(s);
    PostLayoutBorder(s);
    LayoutEffects(s);
    PostLayoutEffects(s);
    LayoutMargin(s);
    PostLayoutMargin(s);
    LayoutRotate(s);
    PostLayoutRotate(s);
    LayoutNormalize(s);
    PostLayoutNormalize(s);
    LayoutRound(s);
    PostLayoutRound(s);
    EndLayout(s);
    return RequestedAction.None;
}

但是不打开图片文件这是不可能的……

ImageState 文档中他们说:

封装正在调整大小的图像的状态。可用于模拟调整大小以及实际执行调整大小。

但我不知道怎么做。

【问题讨论】:

    标签: c# asp.net imageresizer


    【解决方案1】:

    我找到了一个简单的方法来做到这一点。

    我不知道这是否是正确的方法,但它有效:

    ImageBuilder.Current.GetFinalSize(ImageSize, new ResizeSettings(parameters));
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-06-07
      • 2011-07-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-03
      相关资源
      最近更新 更多