public ThumbnailResult Generater(ThumbnailRequest info) { _logger.Debug("begin image "); try { info.OriginalImageFullName = System.IO.Path.GetFullPath(info.OriginalImageFullName); info.SaveImageFullName = System.IO.Path.GetFullPath(info.SaveImageFullName); if (info.Height == null || info.Height.Value == 0) { Make(info.ImageQuality, info.OriginalImageFullName, info.SaveImageFullName, info.Width ?? 0); } else { Make(info.ImageQuality, info.OriginalImageFullName, info.SaveImageFullName, info.Width ?? 0, info.Height.Value); } } catch (Exception ex) { _logger.Error(ex); } _logger.Debug("end image"); return new ThumbnailResult { ContentSize = 0, Height = info.Height ?? 0, Width = info.Width ?? 0 }; }
//public ThumbnailResult Generater(ThumbnailRequest request) //{ // int towidth = request.Width; // int toheight = request.Height; // int x = 0; // int y = 0; // var exifInfos = request.ExifInfos; // var result = new ThumbnailResult { Width = towidth, Height = toheight }; // using (var originalImage = Image.FromFile(request.OriginalImageFullName, true)) // { // if (exifInfos == null) // { // exifInfos = new Dictionary<int, string>(); // try // { // ProcessExifInfo(originalImage, exifInfos); // } // catch // { // } // } // int ow = originalImage.Width; // int oh = originalImage.Height; // switch (request.ThumbMode) // { // case ThumbMode.NHW: // if (toheight > originalImage.Height && towidth > originalImage.Width) // { // towidth = originalImage.Width; // toheight = originalImage.Height; // } // else // { // if ((double)originalImage.Width / (double)towidth > (double)originalImage.Height / (double)toheight) // { // toheight = originalImage.Height * request.Width / originalImage.Width; // } // else // { // towidth = originalImage.Width * request.Height / originalImage.Height; // } // } // break; // case ThumbMode.HW: // break; // case ThumbMode.W: // toheight = originalImage.Height * request.Width / originalImage.Width; // break; // case ThumbMode.H: // towidth = originalImage.Width * request.Height / originalImage.Height; // break; // case ThumbMode.Cut: // if ((double)originalImage.Width / (double)originalImage.Height > (double)towidth / (double)toheight) // { // oh = originalImage.Height; // ow = originalImage.Height * towidth / toheight; // y = 0; // x = (originalImage.Width - ow) / 2; // } // else // { // ow = originalImage.Width; // oh = originalImage.Width * request.Height / towidth; // x = 0; // y = (originalImage.Height - oh) / 2; // } // break; // default: // break; // } // using (Image bitmap = new System.Drawing.Bitmap(towidth, toheight)) // { // var wrapMode = new ImageAttributes(); // wrapMode.SetWrapMode(WrapMode.TileFlipXY); // using (var g = System.Drawing.Graphics.FromImage(bitmap)) // { // g.Clear(Color.White); // g.CompositingQuality = CompositingQuality.HighQuality; // g.InterpolationMode = InterpolationMode.HighQualityBicubic; // g.PixelOffsetMode = PixelOffsetMode.HighQuality; // g.SmoothingMode = SmoothingMode.HighQuality; // g.DrawImage(originalImage, new Rectangle(0, 0, towidth, toheight), x, y, ow, oh, GraphicsUnit.Pixel, wrapMode); // var encoderParms = new EncoderParameters(1); // encoderParms.Param[0] = new EncoderParameter(Encoder.Quality, request.ImageQuality); // bitmap.Save(request.SaveImageFullName, JpegFormat, encoderParms); // result.ContentSize = new FileInfo(request.SaveImageFullName).Length; // } // } // } // return result; //} public ThumbnailResult Generater(ThumbnailRequest info) { throw new NotImplementedException(); }