OK、Web アプリでImageResizer コンポーネントを使用しようとしています。私は次のコードを持っています:
var versions = new Dictionary<string, string>();
//Define the versions to generate
versions.Add("_001", "maxwidth=300&maxheight=300&format=jpg");
versions.Add("_002", "maxwidth=600&maxheight=600&format=jpg");
versions.Add("_003", "maxwidth=1920&maxheight=1080&format=jpg&process=no"); // I expect it not to resave the image if original is smaller
string uploadFolder = "...my folder path...";
if (!Directory.Exists(uploadFolder))
Directory.CreateDirectory(uploadFolder);
//Generate each version
foreach (string suffix in versions.Keys)
{
//Generate a filename (GUIDs are best).
string fileName = Path.Combine(uploadFolder, DEFAULT_IMAGE_NAME + suffix);
//Let the image builder add the correct extension based on the output file type
fileName = ImageBuilder.Current.Build(file, fileName, new ResizeSettings(versions[suffix]), false, true);
}
file.SaveAs(uploadFolder + DEFAULT_IMAGE_NAME + "_000.jpg");
ご覧のとおり、1 つの画像 + 元の画像の 3 つのバージョンを保存しています。ただし、サイズ変更が必要な場合にのみ、画像を再エンコードして再保存する必要があります。したがって、1000x1000 の画像をアップロードすると、main_000.jpg と main_003.jpg が同じであることが期待されます。ただし、そうではありません (ImageResizer はその画像のサイズも変更し、多くの場合、保存されるファイル サイズは main_000.jpg よりも大きくなります)。
パラメータとして process=no を追加しようとしましたが、機能していません。このシナリオがサポートされているかどうか、およびどのパラメーターを追加する必要があるかを知っている人はいますか?