如何生成图像的方形缩略图?

我想从原件创建尺寸为75×75平方的缩略图。 缩略图在一个维度上看起来不会拉伸,因为它不会跟随宽高比。

如果使用了Flickr,您将看到它们生成方形缩略图。 我需要同样的东西。

任何线索或帮助表示赞赏。

编辑:

我在.NET 4.0 C#

我正在寻找以编程方式生成大拇指。 如果没有可用的DLL,则需要批处理function。

这来自Codeproject :

static System.Drawing.Image FixedSize(System.Drawing.Image imgPhoto, int Width, int Height) { int sourceWidth = imgPhoto.Width; int sourceHeight = imgPhoto.Height; int sourceX = 0; int sourceY = 0; int destX = 0; int destY = 0; float nPercent = 0; float nPercentW = 0; float nPercentH = 0; nPercentW = ((float)Width / (float)sourceWidth); nPercentH = ((float)Height / (float)sourceHeight); if (nPercentH < nPercentW) { nPercent = nPercentH; destX = System.Convert.ToInt16((Width - (sourceWidth * nPercent)) / 2); } else { nPercent = nPercentW; destY = System.Convert.ToInt16((Height - (sourceHeight * nPercent)) / 2); } int destWidth = (int)(sourceWidth * nPercent); int destHeight = (int)(sourceHeight * nPercent); Bitmap bmPhoto = new Bitmap(Width, Height, PixelFormat.Format24bppRgb); bmPhoto.SetResolution(imgPhoto.HorizontalResolution, imgPhoto.VerticalResolution); Graphics grPhoto = Graphics.FromImage(bmPhoto); grPhoto.Clear(Color.White); grPhoto.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; grPhoto.DrawImage(imgPhoto, new Rectangle(destX, destY, destWidth, destHeight), new Rectangle(sourceX, sourceY, sourceWidth, sourceHeight), GraphicsUnit.Pixel); grPhoto.Dispose(); return bmPhoto; 

}

ImageMagick是一个很好的图书馆/程序,用于进行图像转换/转换。

调整图像大小 。

如果您对PHP没问题,那么这将对您有所帮助。

如果你在Windows上,你可以用MSPaint实际做到这一点。