を定義することで、.NET C#でサムネイルを作成します。私はサムネイル作成のために、私のウェブサイトに次のコードを使用しています幅
string furl = "~/images/thumbs/" + matchString;
lBlogThumb.ImageUrl = GetThumbnailView(furl, 200, 200);
private string GetThumbnailView(string originalImagePath, int height, int width)
{
//Consider Image is stored at path like "ProductImage\\Product1.jpg"
//Now we have created one another folder ProductThumbnail to store thumbnail image of product.
//So let name of image be same, just change the FolderName while storing image.
string thumbnailImagePath = originalImagePath.Replace("thumbs", "thumbs2");
//If thumbnail Image is not available, generate it.
if (!System.IO.File.Exists(Server.MapPath(thumbnailImagePath)))
{
System.Drawing.Image imThumbnailImage;
System.Drawing.Image OriginalImage = System.Drawing.Image.FromFile(Server.MapPath(originalImagePath));
imThumbnailImage = OriginalImage.GetThumbnailImage(width, height,
new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback), IntPtr.Zero);
imThumbnailImage.Save(Server.MapPath(thumbnailImagePath), System.Drawing.Imaging.ImageFormat.Jpeg);
imThumbnailImage.Dispose();
OriginalImage.Dispose();
}
return thumbnailImagePath;
}
public bool ThumbnailCallback() { return false; }
私はこのコードを変更したい、と幅を定義し、サムネイルを作成することができるだろうのみ。私が頭に浮かべているのは、実際には画像の切り抜き/サイズ変更、静的な幅の使用、比率の維持などです。それは可能ですか?
が、これはあなたが何をしたいですか? newHeight = oldHeight * newWidth/oldWidth、画像をトリミングすると言ったときの意味がわからない - トリミングしてサイズを変更したいですか? –
あなたの助けてくれてありがとう – zekia
idkなぜかこれは私に "メモリ不足"誤って..これのためにexeptionを置くことができる人は誰ですか?私は本当にC#がどのようにメモリを扱うのか知りません。 –